Пример #1
0
 def test_register_parser(self):
     shaape = Shaape(TestUtils.EMPTY_INPUT)
     original_parsers = copy.copy(shaape.parsers())
     overlayparser = OverlayParser()
     shaape.register_parser(overlayparser)
     assert shaape.parsers() == original_parsers + [overlayparser]
     assert_raises(TypeError, shaape.register_parser, CairoBackend())
Пример #2
0
 def test_register_backend(self):
     shaape = Shaape(TestUtils.EMPTY_INPUT)
     original_backends = copy.copy(shaape.backends())
     cairobackend = CairoBackend()
     shaape.register_backend(cairobackend)
     assert shaape.backends() == original_backends + [cairobackend]
     assert_raises(TypeError, shaape.register_backend, OverlayParser())
Пример #3
0
 def test_run(self):
     shaape = Shaape(TestUtils.EMPTY_INPUT)
     for parser in shaape.parsers():
         parser.run = MagicMock()
     for backend in shaape.backends():
         backend.run = MagicMock()
     shaape.run()
     for parser in shaape.parsers():
         parser.run.assert_called_once()
     for backend in shaape.backends():
         backend.run.assert_called_once()
Пример #4
0
 def test_input(self):
     files = [
         f for f in os.listdir(TestAllInput.INPUT_PATH)
         if os.path.isfile(os.path.join(TestAllInput.INPUT_PATH, f))
         and os.path.splitext(f)[1] == '.shaape'
     ]
     results = []
     for f in files:
         f_in = TestAllInput.INPUT_PATH + f
         f_out = TestAllInput.GENERATED_IMAGES_PATH + f + '.png'
         f_expected = TestAllInput.EXPECTED_IMAGES_PATH + f + '.png'
         shaape = Shaape(f_in, f_out)
         shaape.run()
         if False == TestUtils.images_equal(f_out, f_expected):
             results.append([f_out, f_expected])
     if results:
         for result in results:
             print("cp " + result[0] + " " + result[1])
         assert False, "Not all test input images equal their expected images, see image list."
Пример #5
0
 def test_init(self):
     shaape = Shaape(TestUtils.EMPTY_INPUT)
     assert shaape != None