Пример #1
0
    async def test_cmd_execution(self):
        if not is_develop("dffml"):
            self.skipTest("dffml not installed in development mode")

        stdout = io.StringIO()

        with unittest.mock.patch(
                "asyncio.create_subprocess_exec",
                new=mkexec()), contextlib.redirect_stdout(stdout):
            await Develop.cli("lint", "imports")

        self.assertEqual(
            stdout.getvalue().strip(),
            inspect.cleandoc("""
                $ git ls-files '*.py' | xargs autoflake --in-place --remove-all-unused-imports --ignore-init-module-imports
                """),
        )
Пример #2
0
    async def test_files(self):
        if not is_develop("dffml"):
            self.skipTest("dffml not installed in development mode")

        with tempfile.TemporaryDirectory() as tempdir:
            with unittest.mock.patch("asyncio.create_subprocess_exec",
                                     new=mkexec()):
                await Develop.cli("docs", "-target", tempdir)

                for symlink, source in self.symlinks_to_chk:
                    symlink_path = self.docs_root.joinpath(*symlink)
                    source_path = self.root.joinpath(*source)
                    self.assertTrue(symlink_path.exists())
                    self.assertTrue(symlink_path.resolve() == source_path)

                for file_name in self.files_to_check:
                    file_path = pathlib.Path(tempdir).joinpath(*file_name)
                    self.assertTrue(file_path.exists())
Пример #3
0
 async def test_run(self):
     # Skip if not in development mode
     if not is_develop("dffml"):
         self.skipTest("dffml not installed in development mode")
     await Develop.cli("skel", "link")
     common_files = [
         path.relative_to(self.skel.common)
         for path in self.skel.common_files()
     ]
     # At time of writing there are 4 plugins in skel/ change this as needed
     plugins = self.skel.plugins()
     self.assertGreater(len(plugins), 3)
     for plugin in plugins:
         for check in COMMON_FILES:
             with chdir(plugin):
                 self.assertTrue(
                     check.is_symlink(),
                     f"{check.resolve()} is not a symlink",
                 )
Пример #4
0
    async def test_cmd_seq(self):
        if not is_develop("dffml"):
            self.skipTest("dffml not installed in development mode")

        stdout = io.StringIO()

        with unittest.mock.patch(
                "asyncio.create_subprocess_exec",
                new=mkexec()), contextlib.redirect_stdout(
                    stdout), tempfile.TemporaryDirectory() as tempdir:
            await Develop.cli("docs", "-target", tempdir)

        self.assertEqual(
            stdout.getvalue().strip(),
            inspect.cleandoc(f"""
                $ {sys.executable} {self.root}/scripts/docs.py
                $ {sys.executable} {self.root}/scripts/docs_api.py
                $ sphinx-build -W -b html docs {tempdir}
                """),
        )
Пример #5
0
 async def test_run(self):
     # Skip if not in development mode
     if not is_develop("dffml"):
         self.skipTest("dffml not installed in development mode")
     await Develop.cli("skel", "link")
     common_files = [
         path.relative_to(self.skel.common)
         for path in self.skel.common_files()
     ]
     # At time of writing there are 4 plugins in skel/ change this as needed
     plugins = self.skel.plugins()
     self.assertGreater(len(plugins), 3)
     for plugin in plugins:
         for check in COMMON_FILES:
             # We skip the setup.cfg symlink check for blank because it has a
             # custom setup.cfg
             if plugin.name == "blank" and check.name == "setup.cfg":
                 continue
             with chdir(plugin):
                 self.assertTrue(
                     check.is_symlink(),
                     f"{check.resolve()} is not a symlink",
                 )