-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_cli.py
More file actions
76 lines (61 loc) · 2.31 KB
/
test_cli.py
File metadata and controls
76 lines (61 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""Tests for CLI functionality without requiring PyTorch."""
import subprocess
import sys
class TestCLIBasics:
"""Test basic CLI functionality that doesn't require PyTorch."""
def test_cli_help(self):
"""Test that --help works."""
result = subprocess.run(
[sys.executable, "-m", "pytorch_teaching.cli", "--help"],
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 0
assert "pytorch-teach" in result.stdout.lower() or "usage" in result.stdout.lower()
def test_cli_version(self):
"""Test that version command works."""
result = subprocess.run(
[sys.executable, "-m", "pytorch_teaching.cli", "version"],
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 0
assert "2.0.0" in result.stdout
def test_cli_list_lessons(self):
"""Test that list-lessons command works."""
result = subprocess.run(
[sys.executable, "-m", "pytorch_teaching.cli", "list-lessons"],
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 0
assert "Lesson" in result.stdout
def test_cli_info(self):
"""Test that info command works."""
result = subprocess.run(
[sys.executable, "-m", "pytorch_teaching.cli", "info"],
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 0
assert "Python" in result.stdout or "System" in result.stdout
class TestPackageImport:
"""Test that package can be imported."""
def test_import_package(self):
"""Test that pytorch_teaching can be imported."""
import pytorch_teaching
assert hasattr(pytorch_teaching, "__version__")
assert pytorch_teaching.__version__ == "2.0.0"
def test_import_cli(self):
"""Test that CLI module can be imported."""
from pytorch_teaching import cli
assert hasattr(cli, "app")
def test_import_lessons_module(self):
"""Test that lessons module can be imported."""
from pytorch_teaching import lessons # noqa: F401
# Just check it imports without error
assert True