示例#1
0
    def setUp(self):
        self.fileSystem = OSFileSystem()
        self.path = TEMP / "flap_os" / "test.txt"
        self.content = "blahblah blah"

        self.fileSystem.deleteDirectory(TEMP / "flap_os")
        self.fileSystem.deleteDirectory(TEMP / "flatexer_copy")
示例#2
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
示例#3
0
def main(tex_file, output, verbose):
    """
    FLaP merges your LaTeX projects into a single LaTeX file that
    refers to images in the same directory.

    It reads the given root TEX_FILE and generates a flatten version in the
    given OUTPUT directory. It inlines the content of any TeX files refered by
    \\input or \\include but also copies resources such as images (JPG, EPS,
    PDF, etc.) as well as other resources (class and package definitions,
    BibTeX files, etc.).
    """
    Controller(OSFileSystem(), Display(sys.stdout,
                                       verbose)).run(tex_file, output)
示例#4
0
class OSFileSystemTest(TestCase):
    def setUp(self):
        self.fileSystem = OSFileSystem()
        self.path = TEMP / "flap_os" / "test.txt"
        self.content = "blahblah blah"

        self.fileSystem.deleteDirectory(TEMP / "flap_os")
        self.fileSystem.deleteDirectory(TEMP / "flatexer_copy")

    def createAndOpenTestFile(self):
        self.fileSystem.create_file(self.path, self.content)
        return self.fileSystem.open(self.path)

    def testCreateAndOpenFile(self):
        file = self.createAndOpenTestFile()

        self.assertEqual(file.content(), self.content)

    def testCopyAndOpenFile(self):
        file = self.createAndOpenTestFile()

        copyPath = TEMP / "flatexer_copy"

        self.fileSystem.copy(file, copyPath)
        copy = self.fileSystem.open(copyPath / "test.txt")

        self.assertEqual(copy.content(), self.content)

    def test_copyAndRename(self):
        file = self.createAndOpenTestFile()

        copy_path = TEMP / "dir" / "copy.txt"
        self.fileSystem.copy(file, copy_path)

        copy = self.fileSystem.open(copy_path)
        self.assertEqual(copy.content(), self.content)
示例#5
0
    def header(self):
        if self._verbose:
            self._show(self.HEADER)
            self._show(self._horizontal_line())

    def entry(self, file, line, column, code):
        if self._verbose:
            escaped_code = truncate(code.strip().replace("\n", r"\n"),
                                    length=self.WIDTHS[3])
            self._show(self.ENTRY,
                       file=file,
                       line=line,
                       column=column,
                       code=escaped_code)

    def footer(self, count, output):
        if self._verbose:
            self._show(self._horizontal_line())
        self._show(self.SUMMARY, count=count)
        self._show(self.CLOSING, directory=output)

    def _horizontal_line(self):
        return "-" * (sum(self.WIDTHS) + len(self.WIDTHS) - 1) + "\n"

    def _show(self, template, **values):
        self._output.write(template.format(**values))


Controller(OSFileSystem(), Display(sys.stdout, False)).run('doku.tex', 'out')