Skip to content

Commit

Permalink
support python -m dpdata (#649)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Introduced a new command-line interface for easier interaction with
the application.
- **Tests**
- Added tests to verify the correct version output from the new
command-line interface.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jinzhe Zeng <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
njzjz and pre-commit-ci[bot] authored May 2, 2024
1 parent 6e912a2 commit 8536275
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dpdata/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from dpdata.cli import dpdata_cli

if __name__ == "__main__":
dpdata_cli()
10 changes: 10 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import subprocess as sp
import sys
import unittest

from context import dpdata
Expand Down Expand Up @@ -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}"

0 comments on commit 8536275

Please sign in to comment.