Exemplo n.º 1
0
class When_a_folder_is_not_listed_in_the_file_spec(FileSpecContext):
    def given_a_file_spec(self):
        self.spec = FileSpecIdentifier()
        self.spec.initialise(file=io.StringIO())
        self.testdir = self.make_path("acceptance")

    def because_we_check_a_folder(self):
        self.result = self.spec.identify_folder(self.testdir)

    def it_should_not_identify_the_folder_for_tests(self):
        assert (self.result is None)
Exemplo n.º 2
0
class When_a_folder_is_not_listed_in_the_file_spec(FileSpecContext):

    def given_a_file_spec(self):
        self.spec = FileSpecIdentifier()
        self.spec.initialise(file=io.StringIO())
        self.testdir = self.make_path("acceptance")

    def because_we_check_a_folder(self):
        self.result = self.spec.identify_folder(self.testdir)

    def it_should_not_identify_the_folder_for_tests(self):
        assert(self.result is None)
Exemplo n.º 3
0
class When_a_file_is_not_listed_in_the_spec(FileSpecContext):
    def given_a_file_spec(self):
        self.testfile = self.make_path("acceptance", "herbivores", "cows.py")
        file_spec = io.StringIO('')
        self.spec = FileSpecIdentifier()
        self.spec.initialise(file=file_spec, cwd=self.tempdir.name)

    def because_we_check_a_file(self):
        self.result = self.spec.identify_file(self.testfile)

    def it_should_not_identify_the_file_for_tests(self):
        assert (self.result is None)
Exemplo n.º 4
0
class When_a_file_is_listed_in_the_spec(FileSpecContext):

    def given_a_file_spec(self):
        self.testfile = self.make_path("acceptance", "herbivores", "cows.py")
        file_spec = io.StringIO(self.testfile)
        self.spec = FileSpecIdentifier()
        self.spec.initialise(file=file_spec, cwd=self.tempdir.name)

    def because_we_check_a_file(self):
        self.result = self.spec.identify_file(self.testfile)

    def it_should_identify_the_file_for_tests(self):
        assert(self.result is TEST_FILE)
Exemplo n.º 5
0
class When_a_folder_is_the_parent_of_an_item_in_the_spec(FileSpecContext):
    def given_a_file_spec(self):
        self.testdir = self.make_path("acceptance")
        testfile = self.make_path("acceptance", "herbivores", "cows.py")
        file_spec = io.StringIO(testfile)
        self.spec = FileSpecIdentifier()
        self.spec.initialise(file=file_spec, cwd=self.tempdir.name)

    def because_we_check_a_folder(self):
        self.result = self.spec.identify_folder(self.testdir)

    def it_should_identify_the_folder_for_tests(self):
        assert (self.result is TEST_FOLDER)
Exemplo n.º 6
0
class When_loading_the_specs_from_a_file(FileSpecContext):

    def given_a_valid_command_line(self):
        self.tempfile = self.make_path("specs.txt")

        # on linux we should write something like
        # /tmp/afhf293/acceptance-tests/carnivores/lion.py
        # under Windows we should write
        # c:\temp\djauey734\acceptance-tests\carnivores\lion.py
        self.testfile = self.make_path(
            "acceptance-tests",
            "carnivores",
            "lion.py")

        self.testdir = self.make_path("acceptance-tests")

        with io.open(self.tempfile, 'w') as f:
            f.write(self.testfile)
        self.cmd_line = "--filespec=" + self.tempfile

    def because_we_initialise_the_plugin(self):
        self.spec = FileSpecIdentifier()
        self.parser = ExceptionThrowingArgumentParser()
        self.spec.setup_parser(self.parser)
        args = self.parser.parse_args(args=[self.cmd_line])
        self.result = self.spec.initialise(args, None, cwd=self.tempdir.name)

    def it_should_have_initialised(self):
        assert(self.result is True)

    def it_should_identify_a_test_folder(self):
        assert(self.spec.identify_folder(self.testdir) == TEST_FOLDER)

    def it_should_identify_a_test_file(self):
        assert(self.spec.identify_file(self.testfile) == TEST_FILE)
Exemplo n.º 7
0
class When_loading_the_specs_from_a_file(FileSpecContext):
    def given_a_valid_command_line(self):
        self.tempfile = self.make_path("specs.txt")

        # on linux we should write something like
        # /tmp/afhf293/acceptance-tests/carnivores/lion.py
        # under Windows we should write
        # c:\temp\djauey734\acceptance-tests\carnivores\lion.py
        self.testfile = self.make_path("acceptance-tests", "carnivores",
                                       "lion.py")

        self.testdir = self.make_path("acceptance-tests")

        with io.open(self.tempfile, 'w') as f:
            f.write(self.testfile)
        self.cmd_line = "--filespec=" + self.tempfile

    def because_we_initialise_the_plugin(self):
        self.spec = FileSpecIdentifier()
        self.parser = ExceptionThrowingArgumentParser()
        self.spec.setup_parser(self.parser)
        args = self.parser.parse_args(args=[self.cmd_line])
        self.result = self.spec.initialise(args, None, cwd=self.tempdir.name)

    def it_should_have_initialised(self):
        assert (self.result is True)

    def it_should_identify_a_test_folder(self):
        assert (self.spec.identify_folder(self.testdir) == TEST_FOLDER)

    def it_should_identify_a_test_file(self):
        assert (self.spec.identify_file(self.testfile) == TEST_FILE)
Exemplo n.º 8
0
class When_initialising_the_plugin_with_a_valid_command_line:
    def given_a_valid_command_line(self):
        self.cmd_line = "--filespec=foo.txt"
        self.parser = ExceptionThrowingArgumentParser()

    def because_we_initialise_the_plugin(self):
        self.spec = FileSpecIdentifier()
        self.spec.setup_parser(self.parser)
        args = self.parser.parse_args(args=[self.cmd_line])
        self.result = self.spec.initialise(args, None)

    def it_should_have_initialised(self):
        assert (self.result is True)
Exemplo n.º 9
0
class When_initialising_the_plugin_with_a_valid_command_line:

    def given_a_valid_command_line(self):
        self.cmd_line = "--filespec=foo.txt"
        self.parser = ExceptionThrowingArgumentParser()

    def because_we_initialise_the_plugin(self):
        self.spec = FileSpecIdentifier()
        self.spec.setup_parser(self.parser)
        args = self.parser.parse_args(args=[self.cmd_line])
        self.result = self.spec.initialise(args, None)

    def it_should_have_initialised(self):
        assert(self.result is True)