示例#1
0
 def testDirectoryContainsOnlyItsDirectContent(self):
     self.fileSystem.create_file(Path.fromText("dir/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/test2.txt"), "y")
     self.fileSystem.create_file(Path.fromText("dir/more/test.txt"), "x")
     directory = self.fileSystem.open(Path.fromText("dir"))
     self.assertEqual(len(directory.files()), 3, [
                      str(file.path()) for file in directory.files()])
示例#2
0
    def test_as_absolute_with_implicit_current(self):
        path = Path.fromText("test/foo.txt")

        absolute_path = path.absolute_from(Path.fromText("/home/franck"))

        self.assertEqual(absolute_path,
                         Path.fromText("/home/franck/test/foo.txt"))
示例#3
0
 def test_file_creation(self):
     path = Path.fromText("dir/test/source.tex")
     self.fileSystem.create_file(path, "blah")
     
     file = self.fileSystem.open(Path.fromText("dir/test/source.tex"))
     
     self.assertTrue(file.exists())
     self.assertTrue(file.contains("blah"))
示例#4
0
    def test_finding_files_in_the_current_directory(self):
        path = Path.fromText("/root/foo/bar/test.txt")
        self.fileSystem.create_file(path, "blahblah blah")

        self.fileSystem.move_to_directory(Path.fromText("/root/foo"))
        file = self.fileSystem.open(Path.fromText("bar/test.txt"))

        self.assertEqual(file.content(), "blahblah blah")
示例#5
0
    def test_file_creation(self):
        path = Path.fromText("dir/test/source.tex")
        self.fileSystem.create_file(path, "blah")

        file = self.fileSystem.open(Path.fromText("dir/test/source.tex"))

        self.assertTrue(file.exists())
        self.assertTrue(file.contains("blah"))
示例#6
0
    def test_finding_files_in_the_current_directory(self):
        path = Path.fromText("/root/foo/bar/test.txt")
        self.fileSystem.create_file(path, "blahblah blah")

        self.fileSystem.move_to_directory(Path.fromText("/root/foo"))
        file = self.fileSystem.open(Path.fromText("bar/test.txt"))

        self.assertEqual(file.content(), "blahblah blah")
示例#7
0
    def testCopyingFile(self):
        source = Path.fromText("dir/test.txt")
        self.fileSystem.create_file(source, "whatever")
        file = self.fileSystem.open(source)
        destination = Path.fromText("dir2/clone")

        self.fileSystem.copy(file, destination)

        copy = self.fileSystem.open(destination / "test.txt")
        self.assertTrue(copy.exists())
        self.assertEqual(copy.content(), "whatever")
示例#8
0
    def testCopyingFile(self):
        source = Path.fromText("dir/test.txt")
        self.fileSystem.create_file(source, "whatever")
        file = self.fileSystem.open(source)
        destination = Path.fromText("dir2/clone")

        self.fileSystem.copy(file, destination)

        copy = self.fileSystem.open(destination / "test.txt")
        self.assertTrue(copy.exists())
        self.assertEqual(copy.content(), "whatever")
示例#9
0
文件: oofs.py 项目: alcrene/flap
 def files_that_matches(self, pattern):
     path = Path.fromText(str(self._path) + "/" + str(pattern))
     directory = self.fileSystem.open(path.container())
     return [
         any_file for any_file in directory.files()
         if str(any_file.path()).startswith(str(path))
     ]
示例#10
0
文件: engine.py 项目: fchauvel/flap
 def _find(path, directories, extensions, error):
     for any_directory in directories:
         candidates = any_directory.files_that_matches(Path.fromText(path))
         for any_possible_extension in extensions:
             for any_resource in candidates:
                 if any_resource.has_extension(any_possible_extension):
                     return any_resource
     raise error
示例#11
0
文件: engine.py 项目: fchauvel/flap
 def _find(path, directories, extensions, error):
     for any_directory in directories:
         candidates = any_directory.files_that_matches(Path.fromText(path))
         for any_possible_extension in extensions:
             for any_resource in candidates:
                 if any_resource.has_extension(any_possible_extension):
                     return any_resource
     raise error
示例#12
0
文件: __init__.py 项目: fchauvel/flap
def load_tests(loader, tests, pattern):
    file_system = OSFileSystem()
    repository = FileBasedTestRepository(file_system, Path.fromText("tests/acceptance/scenarios"), YamlCodec())
    runner = EndToEndRunner(file_system)
    generate = Generator(repository, runner)
    suite = TestSuite()
    tests = loader.loadTestsFromTestCase(generate.test_class())
    suite.addTests(tests)
    return suite
示例#13
0
文件: __init__.py 项目: alcrene/flap
def load_tests(loader, tests, pattern):
    file_system = OSFileSystem()
    repository = FileBasedTestRepository(file_system, Path.fromText("tests/acceptance/scenarios"), YamlCodec())
    runner = EndToEndRunner(file_system)
    generate = Generator(repository, runner)
    suite = TestSuite()
    tests = loader.loadTestsFromTestCase(generate.test_class())
    suite.addTests(tests)
    return suite
示例#14
0
 def __init__(self):
     super().__init__()
     self.current_directory = Path.fromText(os.getcwd())
示例#15
0
 def testFilteringFilesInDirectory(self):
     self.fileSystem.create_file(Path.fromText("dir/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/test2.txt"), "y")
     self.fileSystem.create_file(Path.fromText("dir/blah"), "z")
     file = self.fileSystem.open(Path.fromText("dir"))
     self.assertEqual(len(file.files_that_matches("test")), 2)
示例#16
0
 def testDirectoryContainsFiles(self):
     self.fileSystem.create_file(Path.fromText("dir/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/test2.txt"), "y")
     file = self.fileSystem.open(Path.fromText("dir"))
     self.assertEqual(len(file.files()), 2)
示例#17
0
    def test_as_absolute_with_absolute_path(self):
        path = Path.fromText("/home/test/foo.txt")

        absolute_path = path.absolute_from(Path.fromText("/home/franck"))

        self.assertEqual(absolute_path, Path.fromText("/home/test/foo.txt"))
示例#18
0
    def test_relative_to_file(self):
        path = Path.fromText("/home/test/foo.txt")

        relative = path.relative_to(Path.fromText("/home/test"))

        self.assertEquals(relative, Path.fromText("foo.txt"))
示例#19
0
 def testDirectoryContainsFiles(self):
     self.fileSystem.create_file(Path.fromText("dir/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/test2.txt"), "y")
     file = self.fileSystem.open(Path.fromText("dir"))
     self.assertEqual(len(file.files()), 2)
示例#20
0
 def testThatMissingFileDoNotExist(self):
     path = Path.fromText("file\\that\\do\\not\\exist.txt")
     file = self.fileSystem.open(path)
     self.assertFalse(file.exists())
示例#21
0
    def test_as_absolute_with_root(self):
        path = ROOT

        absolute_path = path.absolute_from(Path.fromText("/home/franck"))

        self.assertEqual(absolute_path, ROOT)
示例#22
0
 def test_is_absolute_on_windows_paths(self):
     path = Path.fromText("C:\\Users\\franckc\\file.txt")
     self.assertTrue(path.is_absolute())
示例#23
0
 def test_is_absolute_with_relative(self):
     path = Path.fromText("franck/test.tex")
     self.assertFalse(path.is_absolute())
示例#24
0
 def test_is_absolute_on_windows_paths(self):
     path = Path.fromText("C:\\Users\\franckc\\file.txt")
     self.assertTrue(path.is_absolute())
示例#25
0
 def test_is_absolute_on_unix_paths(self):
     path = Path.fromText("/home/franck/test.tex")
     self.assertTrue(path.is_absolute())
示例#26
0
    def test_relative_to_directory(self):
        path = Path.fromText("/home/test/foo.txt")

        relative = path.relative_to(Path.fromText("/home"))

        self.assertEquals(relative, Path.fromText("test/foo.txt"))
示例#27
0
    def test_as_absolute_with_root(self):
        path = ROOT

        absolute_path = path.absolute_from(Path.fromText("/home/franck"))

        self.assertEqual(absolute_path, ROOT)
示例#28
0
    def test_parsing_directory(self):
        path = Path.fromText("project/img/")

        parts = [each.fullname() for each in path.parts()]
        self.assertEqual(parts, ["project", "img"], "Wrong parts!")
示例#29
0
 def testPathBuilding(self):
     path = Path.fromText("\\Users\\franckc\\file.txt")
     
     self.assertEqual(path, ROOT / "Users" / "franckc" / "file.txt")
示例#30
0
    def test_relative_to_directory(self):
        path = Path.fromText("/home/test/foo.txt")

        relative = path.relative_to(Path.fromText("/home"))

        self.assertEqual(relative, Path.fromText("test/foo.txt"))
示例#31
0
 def testFullNameIsAvailable(self):
     path = Path.fromText("/my/dir/test.txt")
     self.fileSystem.create_file(path, "data")
     file = self.fileSystem.open(path)
     self.assertEqual(file.fullname(), "test.txt")
示例#32
0
文件: commons.py 项目: fchauvel/flap
 def _verify_generated_files(self, test_case):
     location = self._file_system.open(Path.fromText("output"))
     actual = LatexProject.extract_from_directory(location)
     actual.assert_is_equivalent_to(test_case._expected)
示例#33
0
 def testFilteringFilesInDirectory(self):
     self.fileSystem.create_file(Path.fromText("dir/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/test2.txt"), "y")
     self.fileSystem.create_file(Path.fromText("dir/blah"), "z")
     file = self.fileSystem.open(Path.fromText("dir"))
     self.assertEqual(len(file.files_that_matches("test")), 1)
示例#34
0
 def test_is_absolute_on_unix_paths(self):
     path = Path.fromText("/home/franck/test.tex")
     self.assertTrue(path.is_absolute())
示例#35
0
文件: engine.py 项目: fchauvel/flap
 def output_directory(self):
     return Path.fromText(self._output)
示例#36
0
 def _do_test_setup(self, project):
     project.setup(self._file_system, Path.fromText(self._directory))
     self._verify(project)
示例#37
0
 def testBasenameIsAvailable(self):
     path = Path.fromText("my/dir/test.txt")
     self.fileSystem.create_file(path, "whatever")
     file = self.fileSystem.open(path)
     self.assertEqual(file.basename(), "test")
示例#38
0
 def _verify(self, project):
     for (path, file) in project.files.items():
         file_on_disk = self._file_system.open(
             Path.fromText(self._directory) / path)
         self.assertEqual(file.content, file_on_disk.content())
示例#39
0
 def testDirectoryContainsOnlyItsDirectContent(self):
     self.fileSystem.create_file(Path.fromText("dir/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/test2.txt"), "y")
     self.fileSystem.create_file(Path.fromText("dir/more/test.txt"), "x")
     directory = self.fileSystem.open(Path.fromText("dir"))
     self.assertEqual(len(directory.files()), 3, [ str(file.path()) for file in directory.files() ])
示例#40
0
 def _create_files(self, *files):
     self._files = files
     for (path, content) in files:
         complete_path = Path.fromText(self._directory + path)
         self._file_system.create_file(complete_path, content)
示例#41
0
    def testParts(self):
        path = Path.fromText("C:\\Users\\franckc\\pub\\JOCC\\main.tex")

        self.verify_parts(path, ["C:", "Users", "franckc", "pub", "JOCC", "main.tex"])
示例#42
0
 def _extract_project(self):
     root = self._file_system.open(Path.fromText(self._directory))
     return LatexProject.extract_from_directory(root)
示例#43
0
 def test_files_that_match_with_multiple_matches(self):
     self.fileSystem.create_file(Path.fromText("dir/foo/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/foo/subtest.txt"), "x")
     directory = self.fileSystem.open(Path.fromText("dir/foo"))
     results = directory.files_that_matches("test")
     self.assertEqual(len(results), 1)
示例#44
0
 def test_files_that_match_with_multiple_matches(self):
     self.fileSystem.create_file(Path.fromText("dir/foo/test.txt"), "x")
     self.fileSystem.create_file(Path.fromText("dir/foo/subtest.txt"), "x")
     directory = self.fileSystem.open(Path.fromText("dir/foo"))
     results = directory.files_that_matches("test")
     self.assertEqual(len(results), 1)
示例#45
0
 def setUp(self):
     self.fileSystem = InMemoryFileSystem()
     self.current_directory = Path.fromText("/temp")
示例#46
0
 def test_remove_trailing_spaces(self):
     path = Path.fromText("/text/ blabla /test.txt")
     self.assertEqual(path, Path.fromText("/text/blabla/test.txt"))
示例#47
0
 def test_create_file_rejects_content_that_is_not_text(self):
     path = Path.fromText("dir/test.txt")
     with self.assertRaises(ValueError):
         self.fileSystem.create_file(path, [1, 2, 3, 4])
示例#48
0
 def setUp(self):
     self.fileSystem = InMemoryFileSystem()
     self.current_directory = Path.fromText("/temp")
示例#49
0
 def testContainingDirectoryIsAvailable(self):
     path = Path.fromText("my\\dir\\test.txt")
     self.fileSystem.create_file(path, "data")
     file = self.fileSystem.open(path)
     self.assertEqual(file.container().path(), ROOT / "my" / "dir")
示例#50
0
 def testPathWithNewlines(self):
     path = Path.fromText("/Root/Foo\nBar\nBaz/home")
     self.verify_parts(path, ["", "Root", "FooBarBaz", "home"])
示例#51
0
 def testBasenameIsAvailable(self):
     path = Path.fromText("my/dir/test.txt")
     self.fileSystem.create_file(path, "whatever")
     file = self.fileSystem.open(path)
     self.assertEqual(file.basename(), "test")
示例#52
0
 def test_create_file_rejects_content_that_is_not_text(self):
     path = Path.fromText("dir/test.txt")
     with self.assertRaises(ValueError):
         self.fileSystem.create_file(path, [1, 2, 3, 4])
示例#53
0
 def test_empty_container(self):
     path = Path.fromText("foo.tex")
     self.assertEquals(CURRENT_DIRECTORY, path.container())
示例#54
0
 def testThatMissingFileDoNotExist(self):
     path = Path.fromText("file\\that\\do\\not\\exist.txt")
     file = self.fileSystem.open(path)
     self.assertFalse(file.exists())
示例#55
0
    def test_without_extension(self):
        path = Path.fromText("/home/test/foo.txt")

        self.assertEquals(path.without_extension(), Path.fromText("/home/test/foo"))
示例#56
0
 def testContainingDirectoryIsAvailable(self):
     path = Path.fromText("my\\dir\\test.txt")
     self.fileSystem.create_file(path, "data")
     file = self.fileSystem.open(path)
     self.assertEqual(file.container().path(), ROOT / "my" / "dir")
示例#57
0
文件: engine.py 项目: fchauvel/flap
 def root_tex_file(self):
     return Path.fromText(self._root_tex_file)
示例#58
0
 def testFullNameIsAvailable(self):
     path = Path.fromText("/my/dir/test.txt")
     self.fileSystem.create_file(path, "data")
     file = self.fileSystem.open(path)
     self.assertEqual(file.fullname(), "test.txt")
示例#59
0
文件: commons.py 项目: alcrene/flap
 def _verify_generated_files(self, test_case):
     location = self._file_system.open(Path.fromText("output"))
     actual = LatexProject.extract_from_directory(location)
     test_case._expected.assert_is_equivalent_to(actual)
示例#60
0
 def test_is_absolute_with_relative(self):
     path = Path.fromText("franck/test.tex")
     self.assertFalse(path.is_absolute())