Example #1
0
def load_test(path, filepath):
    with open(filepath) as testfile:
        header, markup = load_testfile(testfile)

    if not header:
        raise NoHeaderInTestFile("Test file %s has no header" % filepath)

    return TestCase(path, header, markup)
Example #2
0
    def test_load_testfile_small_file(self):
        mockfile = StringIO(textwrap.dedent("""
        ---
        foo: bar
        ---

        Hello World
        ===========

        content
        """))

        expected = ({'foo': 'bar'}, u"Hello World\n===========\n\ncontent")

        result = testfile.load_testfile(mockfile)
        self.assertEquals(result, expected)
Example #3
0
    def test_load_testfile_only_header(self):
        mockfile = StringIO("---\nfoo: bar\n---\n")
        expected = ({'foo': 'bar'}, "")

        result = testfile.load_testfile(mockfile)
        self.assertEquals(result, expected)
Example #4
0
    def test_load_testfile_incomplete_header(self):
        mockfile = StringIO("---\nfoo: bar\n\n")
        expected = (None, "")

        result = testfile.load_testfile(mockfile)
        self.assertEquals(result, expected)
Example #5
0
    def test_load_testfile_empty_file(self):
        mockfile = StringIO("")
        expected = (None, "")

        result = testfile.load_testfile(mockfile)
        self.assertEquals(result, expected)