module pycode.unittest_cst

Short summary

module pyquickhelper.pycode.unittest_cst

Helpers to compress constant used in unit tests.

source on GitHub

Functions

function

truncated documentation

compress_cst

Transforms a huge constant into a sequence of compressed binary strings.

decompress_cst

Transforms a huge constant produced by function compress_cst() into the original value.

Documentation

Helpers to compress constant used in unit tests.

source on GitHub

pyquickhelper.pycode.unittest_cst.compress_cst(data, length=70, as_text=False)[source]

Transforms a huge constant into a sequence of compressed binary strings.

Parameters
  • data – data

  • length – line length

  • as_text – returns the results as text

Returns

results

<<<

from pyquickhelper.pycode.unittest_cst import compress_cst

data = {'values': [0.5, 6.9]}
print(compress_cst(data))

>>>

    [b'/Td6WFoAAATm1rRGAgAhARYAAAB0L+WjAQAVeyJ2YWx1ZXMiOiBbMC41LCA2LjldfQAAAK', b'CzDzOeal0oAAEuFlYJVd8ftvN9AQAAAAAEWVo=']

source on GitHub

pyquickhelper.pycode.unittest_cst.decompress_cst(data)[source]

Transforms a huge constant produced by function compress_cst into the original value.

Parameters
  • data – data

  • length – line length

  • as_text – returns the results as text

Returns

results

<<<

from pyquickhelper.pycode.unittest_cst import compress_cst, decompress_cst

data = {'values': [0.5, 6.9]}
cp = compress_cst(data)
back = decompress_cst(cp)
print(back)

>>>

    {'values': [0.5, 6.9]}

source on GitHub