コード例 #1
0
 def test_doesnt_expand_nonexistent_vars(self):
     with mock.patch.dict("os.environ", self.env):
         e = Expander()
         o = {"foo": "${JOB}_hello", "bar": "x_${PROD}_y"}
         result = e.evaluate(o)
         self.assertIsInstance(result, dict)
         self.assertEqual(result, o)
コード例 #2
0
 def test_expand_dict_target(self):
     e = Expander(**self.context)
     result = e.evaluate({"foo": "x_<shot>_y", "bar": "x_<ct_dept>_y"})
     self.assertIsInstance(result, dict)
     self.assertEqual(result, {
         "foo": "x_/metropolis/shot01/_y",
         "bar": "x_texturing_y"
     })
コード例 #3
0
 def test_expand_env_vars(self):
     with mock.patch.dict("os.environ", self.env):
         e = Expander()
         result = e.evaluate({"foo": "${SHOT}_hello", "bar": "x_${DEPT}_y"})
         self.assertIsInstance(result, dict)
         self.assertEqual(result, {
             "foo": "MT_shot01_hello",
             "bar": "x_texturing_y"
         })
コード例 #4
0
 def test_expand_empty_list_target(self):
     e = Expander(**self.context)
     result = e.evaluate([])
     self.assertIsInstance(result, list)
     self.assertEqual(result, [])
コード例 #5
0
 def test_expand_list_target(self):
     e = Expander(**self.context)
     result = e.evaluate(["x_<shot>_y", "x_<ct_dept>_y"])
     self.assertIsInstance(result, list)
     self.assertEqual(result, ["x_/metropolis/shot01/_y", "x_texturing_y"])
コード例 #6
0
 def test_repeated_tokens(self):
     e = Expander(**self.context)
     result = e.evaluate("x_<Scene>_<Scene>_y")
     self.assertEqual(result, "x_/projects/myscene_/projects/myscene_y")
コード例 #7
0
 def test_mixed_case(self):
     e = Expander(**self.context)
     result = e.evaluate("x_<Scene>_y")
     self.assertEqual(result, "x_/projects/myscene_y")
コード例 #8
0
 def test_bad_value_raises(self):
     e = Expander(**self.context)
     with self.assertRaises(KeyError):
         e.evaluate("<bad>")
コード例 #9
0
 def test_expand_empty_dict_target(self):
     e = Expander(**self.context)
     result = e.evaluate({})
     self.assertIsInstance(result, dict)
     self.assertEqual(result, {})
コード例 #10
0
 def test_expand_value_target(self):
     e = Expander(**self.context)
     result = e.evaluate("x_<home>_y")
     self.assertEqual(result, "x_/users/joebloggs/_y")
コード例 #11
0
 def test_invalid_when_expr_invalid(self):
     e = Expander(**self.context)
     with self.assertRaises(ValueError):
         e.evaluate("/prefix/<pad start X>/<Scene>.<pad start 4>.exr")
コード例 #12
0
 def test_expand_value_with_expr_when_identical_expr_appears_twice(self):
     e = Expander(**self.context)
     result = e.evaluate("/prefix/<pad start 4>/<Scene>.<pad start 4>.exr")
     self.assertEqual(result, "/prefix/0020/foo.0020.exr")
コード例 #13
0
 def test_expand_value_with_several_plugins(self):
     e = Expander(start=20, outpath="C:\\my\\path")
     result = e.evaluate("<posix outpath>/foo.<pad start 4>.exr")
     self.assertEqual(result, "/my/path/foo.0020.exr")
コード例 #14
0
 def test_expand_value_with_expr(self):
     e = Expander(**self.context)
     result = e.evaluate("/prefix/<Scene>.<pad start 4>.exr")
     self.assertEqual(result, "/prefix/foo.0020.exr")
コード例 #15
0
 def test_bad_list_value_raises(self):
     e = Expander(**self.context)
     with self.assertRaises(KeyError):
         e.evaluate(["<bad>", "directories"])
コード例 #16
0
 def test_expand_numeric_value_target(self):
     e = Expander(**self.context)
     result = e.evaluate("x_<frames>_y")
     self.assertEqual(result, "x_20_y")
コード例 #17
0
 def test_expand_numeric_value_is_string(self):
     e = Expander(**self.context)
     result = e.evaluate("<frames>")
     self.assertIsInstance(result, str)
     self.assertEqual(result, "20")
コード例 #18
0
 def test_bad_dict_value_raises(self):
     e = Expander(**self.context)
     with self.assertRaises(KeyError):
         e.evaluate({"foo": "<bad>", "bar": "directories"})
コード例 #19
0
 def test_bad_dict_value_does_not_raise_if_safe(self):
     e = Expander(safe=True, **self.context)
     result = e.evaluate("x_<bad>_y")
     self.assertEqual(result, "x_<bad>_y")