Created
July 30, 2020 10:49
-
-
Save smarek/38721c9bfd2b0860e746095265c0f761 to your computer and use it in GitHub Desktop.
kaitai tests translator python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/translator/src/main/scala/io/kaitai/struct/testtranslator/specgenerators/PythonSG.scala b/translator/src/main/scala/io/kaitai/struct/testtranslator/specgenerators/PythonSG.scala | |
index 327d3df0..0b64d616 100644 | |
--- a/translator/src/main/scala/io/kaitai/struct/testtranslator/specgenerators/PythonSG.scala | |
+++ b/translator/src/main/scala/io/kaitai/struct/testtranslator/specgenerators/PythonSG.scala | |
@@ -56,7 +56,9 @@ class PythonSG(spec: TestSpec, provider: ClassTypeProvider) extends BaseGenerato | |
override def nullAssert(actual: Ast.expr): Unit = { | |
val actStr = translateAct(actual) | |
- out.puts(s"self.assertIsNone($actStr)") | |
+ val attrStr = actStr.substring(actStr.lastIndexOf('.') + 1) | |
+ val inStr = actStr.substring(0, actStr.lastIndexOf('.')) | |
+ out.puts(s"""self.assertIsNone($actStr if hasattr($inStr, "$attrStr") else None)""") | |
} | |
override def trueArrayAssert(check: TestAssert, elType: DataType, elts: Seq[Ast.expr]): Unit = |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment