コード例 #1
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
 def setUp(self):
     self.project = a_project().with_main_file("blabla").build()
     self.expected = a_project().with_merged_file("blabla").build()
     self.test_case_name = "foo"
     self.output = [Fragment("test.tex", 1, 1, r"\input{foo}")]
     self.test_case = FlapTestCase(
         self.test_case_name,
         self.project,
         self.expected,
         None,
         False,
         self.output)
コード例 #2
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
 def _verify(self, test_cases):
     self.assertEqual(1, len(test_cases))
     expected = FlapTestCase(
         "test 1",
         a_project().with_main_file(self.LATEX_CODE).build(),
         a_project().with_merged_file(self.LATEX_CODE).build())
     self.assertEqual(expected, test_cases[0])
コード例 #3
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
 def test_differs_from_an_equivalent_but_with_different_output(self):
     self.assertNotEqual(
         FlapTestCase(
             "foo",
             a_project().with_main_file("blabla").build(),
             a_project().with_merged_file("blabla").build(),
             output=[Fragment("test.tex", 123, 0, r"\input{foo}")]),
         self.test_case)
コード例 #4
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
 def setUp(self):
     self.project = a_project().with_main_file("blabla").build()
     self.expected = a_project().with_merged_file("blabla").build()
     self.test_case_name = "foo"
     self.test_case = FlapTestCase(
         self.test_case_name,
         self.project,
         self.expected,
         skipped=True)
コード例 #5
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
 def test_differs_from_an_equivalent_but_skipped_case(self):
     self.assertNotEqual(
         FlapTestCase(
             "foo",
             a_project().with_main_file("blabla").build(),
             a_project().with_merged_file("blabla").build(),
             None,
             True,
             [Fragment("test.tex", 1, 1, r"\input{foo}")]),
         self.test_case)
コード例 #6
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
 def test_differs_from_a_project_with_another_expectation(self):
     self.assertNotEqual(
         FlapTestCase(
             "foo",
             a_project().with_main_file("blabla").build(),
             a_project().with_merged_file("something different").build(),
             None,
             False,
             [Fragment("test.tex", 1, 1, r"\input{foo}")]),
         self.test_case)
コード例 #7
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
 def test_equals_a_similar_test_case(self):
     self.assertEqual(
         FlapTestCase(
             "foo",
             a_project().with_main_file("blabla").build(),
             a_project().with_merged_file("blabla").build(),
             None,
             False,
             [Fragment("test.tex", 1, 1, r"\input{foo}")]),
         self.test_case)
コード例 #8
0
ファイル: yaml.py プロジェクト: fchauvel/flap
 def extract_from(self, file):
     content = yaml.safe_load(StringIO(file.content()))
     arguments = [
         self._extract_name_from(content),
         self._extract_project_from(content),
         self._extract_expected_from(content),
         self._extract_invocation_from(content),
         self._extract_is_skipped_from(content),
         self._extract_outputs(content)
     ]
     return FlapTestCase(*arguments)
コード例 #9
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
    def test_parsing_a_skipped_yaml_code(self):
        yaml_file = self._create_file(YamlTest.that_is_skipped("Test 1"))
        test_case = self._read_test_case_from(yaml_file)

        expected = FlapTestCase(
            "Test 1",
            a_project().with_main_file("blabla").build(),
            a_project().with_merged_file("blabla").build(),
            skipped=True)

        self.assertEqual(expected, test_case)
コード例 #10
0
ファイル: test_yaml.py プロジェクト: alcrene/flap
    def test_loading_test_case_with_latex_code(self):
        yaml_file = self._create_file(YamlTest.with_latex_code())

        test_case = self._read_test_case_from(yaml_file)

        expected = FlapTestCase(
                        "test 1",
                        a_project().with_main_file("\\documentclass{article}\n\\begin{document}\n  This is a simple \\LaTeX document!\n\\end{document}").build(),
                        a_project().with_merged_file("\\documentclass{article}\n\\begin{document}\n  This is a simple \\LaTeX document!\n\\end{document}").build())

        self.assertEqual(expected, test_case)
コード例 #11
0
ファイル: test_yaml.py プロジェクト: alcrene/flap
    def test_parsing_a_test_case_with_invocation(self):
        yaml_file = self._create_file(YamlTest.that_includes_invocation("Test 1"))
        test_case = self._read_test_case_from(yaml_file)

        expected = FlapTestCase(
                        "Test 1",
                        a_project().with_main_file("blabla").build(),
                        a_project().with_merged_file("blabla").build(),
                        Invocation(tex_file="foo.tex"),
                        skipped=False)

        self.assertEqual(expected, test_case)
コード例 #12
0
ファイル: test_yaml.py プロジェクト: alcrene/flap
    def test_parsing_a_test_case_with_expected_outputs(self):
        yaml_file = self._create_file(YamlTest.that_includes_expected_outputs("Test 1"))
        test_case = self._read_test_case_from(yaml_file)

        expected = FlapTestCase(
                        "Test 1",
                        a_project().with_main_file("blabla").build(),
                        a_project().with_merged_file("blabla").build(),
                        None,
                        False,
                        [Fragment("main.tex", 1, 1, "\\input{result}")])

        self.assertEqual(expected, test_case)
コード例 #13
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
 def test_reject_empty_names(self):
     with self.assertRaises(ValueError):
         FlapTestCase("", self.project, self.expected)
コード例 #14
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
class FlapTestCaseTests(TestCase):

    def setUp(self):
        self.project = a_project().with_main_file("blabla").build()
        self.expected = a_project().with_merged_file("blabla").build()
        self.test_case_name = "foo"
        self.output = [Fragment("test.tex", 1, 1, r"\input{foo}")]
        self.test_case = FlapTestCase(
            self.test_case_name,
            self.project,
            self.expected,
            None,
            False,
            self.output)

    def test_is_not_skipped(self):
        self.assertFalse(self.test_case.is_skipped)

    def test_name_is_exposed(self):
        self.assertEqual(self.test_case_name, self.test_case.name)

    def test_reject_empty_names(self):
        with self.assertRaises(ValueError):
            FlapTestCase("", self.project, self.expected)

    def test_project_is_exposed(self):
        self.assertIs(self.project, self.test_case.project)

    def test_expectation_is_exposed(self):
        self.assertIs(self.expected, self.test_case.expected)

    def test_equals_itself(self):
        self.assertEqual(self.test_case, self.test_case)

    def test_equals_a_similar_test_case(self):
        self.assertEqual(
            FlapTestCase(
                "foo",
                a_project().with_main_file("blabla").build(),
                a_project().with_merged_file("blabla").build(),
                None,
                False,
                [Fragment("test.tex", 1, 1, r"\input{foo}")]),
            self.test_case)

    def test_differs_from_a_project_with_another_invocation(self):
        self.assertNotEqual(
            FlapTestCase(
                "foo",
                a_project().with_main_file("blabla").build(),
                a_project().with_merged_file("something different").build(),
                Invocation("foo.tex"),
                False,
                [Fragment("test.tex", 1, 1, r"\input{foo}")]),
            self.test_case)

    def test_differs_from_a_project_with_another_expectation(self):
        self.assertNotEqual(
            FlapTestCase(
                "foo",
                a_project().with_main_file("blabla").build(),
                a_project().with_merged_file("something different").build(),
                None,
                False,
                [Fragment("test.tex", 1, 1, r"\input{foo}")]),
            self.test_case)

    def test_differs_from_an_equivalent_but_skipped_case(self):
        self.assertNotEqual(
            FlapTestCase(
                "foo",
                a_project().with_main_file("blabla").build(),
                a_project().with_merged_file("blabla").build(),
                None,
                True,
                [Fragment("test.tex", 1, 1, r"\input{foo}")]),
            self.test_case)

    def test_differs_from_an_equivalent_but_with_different_output(self):
        self.assertNotEqual(
            FlapTestCase(
                "foo",
                a_project().with_main_file("blabla").build(),
                a_project().with_merged_file("blabla").build(),
                output=[Fragment("test.tex", 123, 0, r"\input{foo}")]),
            self.test_case)

    def test_test_with(self):
        runner = MagicMock()
        self.test_case.run_with(runner)
        runner.test.assert_called_once_with(
            self.test_case.name,
            self.test_case._project,
            self.test_case._expected)
コード例 #15
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
 def setUp(self):
     self.project = a_project().with_main_file("blabla").build()
     self.expected = a_project().with_merged_file("blabla").build()
     self.test_case_name = "foo"
     self.output = [Fragment("test.tex", 1, 1, r"\input{foo}")]
     self.test_case = FlapTestCase(self.test_case_name, self.project, self.expected, False, self.output)
コード例 #16
0
ファイル: test_yaml.py プロジェクト: fchauvel/flap
class FlapTestCaseTests(TestCase):

    def setUp(self):
        self.project = a_project().with_main_file("blabla").build()
        self.expected = a_project().with_merged_file("blabla").build()
        self.test_case_name = "foo"
        self.output = [Fragment("test.tex", 1, 1, r"\input{foo}")]
        self.test_case = FlapTestCase(self.test_case_name, self.project, self.expected, False, self.output)

    def test_is_not_skipped(self):
        self.assertFalse(self.test_case.is_skipped)

    def test_name_is_exposed(self):
        self.assertEqual(self.test_case_name, self.test_case.name)

    def test_reject_empty_names(self):
        with self.assertRaises(ValueError):
            FlapTestCase("", self.project, self.expected)

    def test_project_is_exposed(self):
        self.assertIs(self.project, self.test_case.project)

    def test_expectation_is_exposed(self):
        self.assertIs(self.expected, self.test_case.expected)

    def test_equals_itself(self):
        self.assertEquals(self.test_case, self.test_case)

    def test_equals_a_similar_test_case(self):
        self.assertEqual(
            FlapTestCase(
                "foo",
                a_project().with_main_file("blabla").build(),
                a_project().with_merged_file("blabla").build(),
                False,
                [Fragment("test.tex", 1, 1, r"\input{foo}")]),
            self.test_case)

    def test_differs_from_a_project_with_another_expectation(self):
        self.assertNotEqual(
            FlapTestCase(
                "foo",
                a_project().with_main_file("blabla").build(),
                a_project().with_merged_file("something different").build(),
                False,
                [Fragment("test.tex", 1, 1, r"\input{foo}")]),
            self.test_case)

    def test_differs_from_an_equivalent_but_skipped_case(self):
        self.assertNotEqual(
            FlapTestCase(
                "foo",
                a_project().with_main_file("blabla").build(),
                a_project().with_merged_file("blabla").build(),
                True,
                [Fragment("test.tex", 1, 1, r"\input{foo}")]),
            self.test_case)

    def test_differs_from_an_equivalent_but_with_different_output(self):
        self.assertNotEqual(
            FlapTestCase(
                "foo",
                a_project().with_main_file("blabla").build(),
                a_project().with_merged_file("blabla").build(),
                output=[Fragment("test.tex", 123, 0, r"\input{foo}")]),
            self.test_case)

    def test_test_with(self):
        runner = MagicMock()
        self.test_case.run_with(runner)
        runner.test.assert_called_once_with(self.test_case.name, self.test_case._project, self.test_case._expected)