Safe Haskell | None |
---|
Unittests for Ganeti.Pyvalue
Synopsis
- caseByteStringsToBytes :: Assertion
- testPyValue :: Test
Arbitrary instances
caseByteStringsToBytes :: Assertion Source #
Custom HUnit test to check the correspondence between ByteStrings and Python bytes. We use ast.literal_eval to evaluate the byte literals and then write the resulting bytestrings back to Haskell for comparison.
For the technical background of this unit test, check the documentation of "case_py_compat_types" of testhsTestGanetiOpcodes.hs
Note that System.Process.readProcessWithExitCode (used by runPython) returns Python's stdout as a String, by calling hGetContents on the standard output handle. This means that data is decoded using the system locale, making the channel not 8-bit-clean when run with a non-UTF-8 locale (such as POSIX). We could use System.Process.Typed to get past this problem, but that's an extra dependency not used elsewhere. Instead we work around this issue by base64-encoding the UTF-8 output on the Python side.
testPyValue :: Test Source #