def init(self) -> None: """Initializes tests content.""" os.mkdir(self._tests) write_to_file( path=os.path.join(self._tests, "__init__.py"), content=f'"""Package contains a set of interfaces to test ' f'`{self._name}` application."""{Line.NEW}', )
def make_as_tool(self) -> None: """Creates executable file.""" write_to_file( path=os.path.join(self._name, "__main__.py"), content=( '"""Represents executable entrypoint ' f'for `{self._name}` application."""' f'{Line.NEW.by_(3)}def main() -> None:{Line.NEW} """' f'Runs `{self._name}` application."""' f"{Line.NEW.by_(2)} pass{Line.NEW.by_(3)}" f'if __name__ == "__main__":{Line.NEW} main(){Line.NEW}' ), )
def init(self) -> None: """Initializes an application content.""" os.mkdir(self._name) write_to_file( path=os.path.join(self._name, "__init__.py"), content=( '"""Package contains a set of ' f'interfaces to operate `{self._name}` application."""' f" {Line.NEW.by_(2)}__author__: str = " f'"{self._user.name}"{Line.NEW}__email__: str =' f' "{self._user.email}"' f'{Line.NEW}__license__: str = "MIT"{Line.NEW}' f'__copyright__: str = f"Copyright ' f'{datetime.now().year}, {{__author__}}"{Line.NEW}' f'__version__: str = "0.0.0"{Line.NEW.by_(2)}' f"__all__: tuple = (){Line.NEW.by_(2)}" f"app = None{Line.NEW}" ), )
def make_helpers(self) -> None: """Creates tests helpers.""" write_to_file( path=os.path.join(self._tests, "markers.py"), content=( f"# flake8: noqa{Line.NEW}" f"import _pytest.mark{Line.NEW}import pytest{Line.NEW.by_(2)}" f"unit: _pytest.mark.MarkDecorator = pytest.mark.unit{Line.NEW}" ), ) write_to_file( path=os.path.join(self._tests, "conftest.py"), content=( f"# flake8: noqa{Line.NEW}" f"from _pytest.config.argparsing import Parser{Line.NEW}" f"from _pytest.fixtures import " f"SubRequest{Line.NEW}import pytest{Line.NEW}" ), ) write_to_file( path=os.path.join(self._tests, "test_sample.py"), content=f"# flake8: noqa{Line.NEW}" f"import pytest{Line.NEW}" f"from tests.markers import unit{Line.NEW.by_(2)}" f"pytestmark = unit{Line.NEW.by_(3)}" f"def test_me() -> None:{Line.NEW} assert True{Line.NEW}", )
def build_package(self) -> None: """Builds packaging files.""" replace_content( str(Template.CHANGELOG), from_replace="<date>", to_replace="{:%d.%m.%Y}".format(datetime.now()), ) replace_content( str(Template.MANIFEST), from_replace="<package>", to_replace=self._name, ) replace_content( str(Template.PYPIRC), from_replace="<username>", to_replace=self._user.name.lower().replace(" ", "."), ) replace_content( str(Template.SETUP), from_replace="tooling", to_replace=self._name ) replace_content( str(Template.RUNTIME), from_replace="<version>", to_replace=".".join(map(str, sys.version_info[:3])), ) replace_content( str(Template.PROCFILE), from_replace="<package>", to_replace=self._name, ) write_to_file( path=f"{self._name}.py", content=f"# flake8: noqa{Line.NEW}" '"""Module contains entrypoint interfaces for ' f'an application."""{Line.NEW.by_(2)}' f"from {self._name} import app{Line.NEW}", )