Unverified Commit 5ca4c89b authored by h7x4's avatar h7x4
Browse files

pkgs-lib/pythonVars: add test

parent b37cd292
Loading
Loading
Loading
Loading
+57 −0
Original line number Diff line number Diff line
@@ -904,6 +904,63 @@ runBuildTests {
    '';
  };

  pythonVars = shouldPass (
    let
      format = formats.pythonVars { };
    in
    {
      inherit format;
      input = {
        _imports = [
          "re"
          "a.b.c"
        ];

        int = 10;
        float = 3.141;
        bool = true;
        str = "foo";
        str_special = "foo\ntesthello'''";
        null = null;
        list = [
          null
          1
          "str"
          true
          (format.lib.mkRaw "1 if True else 2")
        ];
        attrs = {
          foo = null;
          conditional = format.lib.mkRaw "1 if True else 2";
        };
        func = format.lib.mkRaw "re.findall(r'\\bf[a-z]*', 'which foot or hand fell fastest')";
      };
      expected = ''
        import re
        import a.b.c

        attrs = {
            "conditional": 1 if True else 2,
            "foo": None,
        }
        bool = True
        float = 3.141
        func = re.findall(r"\bf[a-z]*", "which foot or hand fell fastest")
        int = 10
        list = [
            None,
            1,
            "str",
            True,
            1 if True else 2,
        ]
        null = None
        str = "foo"
        str_special = "foo\ntesthello''''"
      '';
    }
  );

  phpReturn = shouldPass {
    format = formats.php { };
    input = {