Пример #1
0
 def test__init__should_ignore_comment_lines(self):
     init = textwrap.dedent("""\
         #some parameters
         x = 2
         # this is a comment at column 0
           # this is an indented comment
           y = 3
         # this is a comment line containing an 'equals' sign: n=42
         """)
     P = SimpleParameterSet(init)
     self.assertEqual(P["x"], 2)
     self.assertEqual(P["y"], 3)
     self.assertEqual(set(P.as_dict().keys()), set(["x", "y"]))
Пример #2
0
 def test__init__should_ignore_comment_lines(self):
     init = textwrap.dedent("""\
         #some parameters
         x = 2
         # this is a comment at column 0
           # this is an indented comment
           y = 3
         # this is a comment line containing an 'equals' sign: n=42
         """)
     P = SimpleParameterSet(init)
     self.assertEqual(P["x"], 2)
     self.assertEqual(P["y"], 3)
     self.assertEqual(set(P.as_dict().keys()), set(["x", "y"]))
Пример #3
0
 def test__pop(self):
     P = SimpleParameterSet("x = 2\ny = 3")
     self.assertEqual(P.pop('x'), 2)
     self.assertEqual(P.as_dict(), {'y': 3})
     self.assertEqual(P.pop('foo', 42), 42)
     self.assertEqual(P.pop('foo', None), None)
Пример #4
0
 def test__pop(self):
     P = SimpleParameterSet("x = 2\ny = 3")
     self.assertEqual(P.pop('x'), 2)
     self.assertEqual(P.as_dict(), {'y': 3})
     self.assertEqual(P.pop('foo', 42), 42)
     self.assertEqual(P.pop('foo', None), None)