Esempio n. 1
0
    def test_errors3(self):
        with self.assertRaises(ValueError) as m:
            config.read_config(SOURCES + ['}{'])
        expected = """\
Cannot load:
<argument 4>: while parsing a block node
expected the node content, but found '}'
  in "<unicode string>", line 1, column 1:
    }{
    ^
"""
        assert m.exception.args[0] == expected
Esempio n. 2
0
 def test_config(self):
     s2 = {'sources': SOURCES[:-1] + ['s.sh']}
     for sources in (SOURCES, s2):
         actual = config.read_config(sources)
         expected = {
             'width': 100,
             'sources': [Path('s.py'), Path('s.sh')],
             'upload': True,
             'verbose': True,
         }
         assert actual == expected
Esempio n. 3
0
 def test_errors7(self):
     with self.assertRaises(TypeError) as m:
         config.read_config([[]])
     assert m.exception.args[0] == 'Expected str or dict'
Esempio n. 4
0
    def test_errors6(self):
        flags = vars(parse.parse('s.py [] --svg=ph/'.split()))

        with self.assertRaises(TypeError) as m:
            config.read_config(flags)
        assert m.exception.args[0] == 'Expected str or dict'
Esempio n. 5
0
 def test_errors5(self):
     with self.assertRaises(ValueError) as m:
         config.read_config({'sources': ['s.py'], 'frog': 'toad'})
     assert m.exception.args[0] == 'Invalid for config: frog\n'
Esempio n. 6
0
 def test_errors4(self):
     with self.assertRaises(ValueError) as m:
         config.read_config({'foo': 'bar'})
     assert m.exception.args[0] == 'No source file given'
Esempio n. 7
0
 def test_errors2(self):
     with self.assertRaises(ValueError) as m:
         config.read_config(SOURCES + ['s.junk'])
     assert m.exception.args[0] == 'Suffix unknown: s.junk\n'
Esempio n. 8
0
 def test_errors1(self):
     with self.assertRaises(ValueError) as m:
         config.read_config(SOURCES + ['dont_exist.py'])
     assert m.exception.args[0] == 'Cannot find dont_exist.py\n'
Esempio n. 9
0
 def test_svg4(self):
     flags = vars(parse.parse('s.py c3.yml --svg'.split()))
     actual = config.read_config(flags)
     expected = dict(EMPTY, sources=[Path('s.py')], svg=None)
     assert actual == expected
Esempio n. 10
0
 def test_svg1(self):
     sources = [{'sources': ['s.py'], 'svg': 'ph/'}, {'svg': None}]
     actual = config.read_config(sources)
     expected = {'sources': [Path('s.py')], 'svg': None}
     assert actual == expected