From 44eb65262caf9e65e05b066657fc58110f90c06a Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Wed, 1 May 2024 18:35:25 -0400 Subject: [PATCH 1/2] support `python -m dpdata` Signed-off-by: Jinzhe Zeng --- dpdata/__main__.py | 4 ++++ tests/test_cli.py | 10 ++++++++++ 2 files changed, 14 insertions(+) create mode 100644 dpdata/__main__.py diff --git a/dpdata/__main__.py b/dpdata/__main__.py new file mode 100644 index 000000000..aad1556fa --- /dev/null +++ b/dpdata/__main__.py @@ -0,0 +1,4 @@ +from dpdata.cli import dpdata_cli + +if __name__ == "__main__": + dpdata_cli() diff --git a/tests/test_cli.py b/tests/test_cli.py index 423b8896a..5f9c3b669 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,4 +1,5 @@ import subprocess as sp +import sys import unittest from context import dpdata @@ -26,3 +27,12 @@ def setUpClass(cls) -> None: @classmethod def tearDownClass(cls) -> None: cls.system = None + + +class TestClassScript(unittest.TestCase): + def test_class_script(self): + expected_version = dpdata.__version__ + output = sp.check_output( + [sys.executable, "-m", "dpdata", "--version"] + ).decode("ascii") + assert output.splitlines()[0] == f"dpdata v{expected_version}" From ee452c07f70b270f13656fe298a59cba7619ebb6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 22:35:47 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_cli.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 5f9c3b669..200a1c1ef 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -32,7 +32,7 @@ def tearDownClass(cls) -> None: class TestClassScript(unittest.TestCase): def test_class_script(self): expected_version = dpdata.__version__ - output = sp.check_output( - [sys.executable, "-m", "dpdata", "--version"] - ).decode("ascii") + output = sp.check_output([sys.executable, "-m", "dpdata", "--version"]).decode( + "ascii" + ) assert output.splitlines()[0] == f"dpdata v{expected_version}"