fast-dev-cli 0.10.0__tar.gz → 0.10.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/PKG-INFO +3 -3
  2. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/README.md +2 -2
  3. fast_dev_cli-0.10.1/fast_dev_cli/__init__.py +1 -0
  4. fast_dev_cli-0.10.1/fast_dev_cli/__main__.py +3 -0
  5. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/fast_dev_cli/cli.py +21 -15
  6. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/pyproject.toml +1 -1
  7. fast_dev_cli-0.10.1/scripts/check.py +19 -0
  8. fast_dev_cli-0.10.1/scripts/format.py +14 -0
  9. fast_dev_cli-0.10.1/scripts/test.py +47 -0
  10. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/tests/test_fast_test.py +28 -16
  11. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/tests/test_lint.py +14 -2
  12. fast_dev_cli-0.10.1/tests/test_poetry_version_plugin.py +70 -0
  13. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/tests/test_tag.py +7 -1
  14. fast_dev_cli-0.10.0/fast_dev_cli/__init__.py +0 -1
  15. fast_dev_cli-0.10.0/fast_dev_cli/__main__.py +0 -3
  16. fast_dev_cli-0.10.0/scripts/check.sh +0 -11
  17. fast_dev_cli-0.10.0/scripts/format.sh +0 -6
  18. fast_dev_cli-0.10.0/scripts/test.sh +0 -6
  19. fast_dev_cli-0.10.0/tests/test_poetry_version_plugin.py +0 -62
  20. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/LICENSE +0 -0
  21. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/fast_dev_cli/py.typed +0 -0
  22. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/pdm_build.py +0 -0
  23. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/tests/__init__.py +0 -0
  24. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/tests/conftest.py +0 -0
  25. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/tests/test_bump.py +0 -0
  26. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/tests/test_functions.py +0 -0
  27. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/tests/test_runserver.py +0 -0
  28. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/tests/test_sync.py +0 -0
  29. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/tests/test_upgrade.py +0 -0
  30. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/tests/test_upload.py +0 -0
  31. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/tests/test_version.py +0 -0
  32. {fast_dev_cli-0.10.0 → fast_dev_cli-0.10.1}/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fast-dev-cli
3
- Version: 0.10.0
3
+ Version: 0.10.1
4
4
  Summary: Python project development tool.
5
5
  Author-Email: Waket Zheng <waketzheng@gmail.com>>
6
6
  Classifier: Development Status :: 4 - Beta
@@ -78,9 +78,9 @@ Python 3.10+
78
78
  <div class="termy">
79
79
 
80
80
  ```bash
81
- pip install "fast-dev-cli"
81
+ pip install fast-dev-cli
82
82
  ```
83
- *Will install: fast-dev-cli typer ruff mypy bumpversion pytest coverage*
83
+ *Will install: fast-dev-cli emoji typer ruff mypy bumpversion2 pytest coverage*
84
84
 
85
85
  </div>
86
86
 
@@ -43,9 +43,9 @@ Python 3.10+
43
43
  <div class="termy">
44
44
 
45
45
  ```bash
46
- pip install "fast-dev-cli"
46
+ pip install fast-dev-cli
47
47
  ```
48
- *Will install: fast-dev-cli typer ruff mypy bumpversion pytest coverage*
48
+ *Will install: fast-dev-cli emoji typer ruff mypy bumpversion2 pytest coverage*
49
49
 
50
50
  </div>
51
51
 
@@ -0,0 +1 @@
1
+ __version__ = "0.10.1"
@@ -0,0 +1,3 @@
1
+ from fast_dev_cli.cli import main
2
+
3
+ main()
@@ -592,6 +592,15 @@ class LintCode(DryRun):
592
592
  and not load_bool("NO_DMYPY")
593
593
  )
594
594
 
595
+ @staticmethod
596
+ def get_package_name() -> str:
597
+ root = Project.get_work_dir(allow_cwd=True)
598
+ package_maybe = (root.name.replace("-", "_"), "src")
599
+ for name in package_maybe:
600
+ if root.joinpath(name).is_dir():
601
+ return name
602
+ return "."
603
+
595
604
  @classmethod
596
605
  def to_cmd(cls: Type[Self], paths=".", check_only=False, bandit=False) -> str:
597
606
  cmd = ""
@@ -611,7 +620,7 @@ class LintCode(DryRun):
611
620
  if is_venv():
612
621
  if not cls.check_lint_tool_installed():
613
622
  should_run_by_tool = True
614
- if check_call("python -c 'import fast_dev_cli'"):
623
+ if check_call('python -c "import fast_dev_cli"'):
615
624
  command = 'python -m pip install -U "fast_dev_cli"'
616
625
  tip = "You may need to run following command to install lint tools:"
617
626
  secho(f"{tip}\n\n {command}\n", fg="yellow")
@@ -625,15 +634,7 @@ class LintCode(DryRun):
625
634
  if bandit or load_bool("FASTDEVCLI_BANDIT"):
626
635
  command = prefix + "bandit"
627
636
  if paths == ".": # fast check --bandit
628
- command += " -r"
629
- root = Project.get_work_dir(allow_cwd=True)
630
- package_maybe = (root.name.replace("-", "_"), "src")
631
- for name in package_maybe:
632
- if root.joinpath(name).is_dir():
633
- command += " " + name
634
- break
635
- else:
636
- command += " ."
637
+ command += " -r " + cls.get_package_name()
637
638
  cmd += " && " + command
638
639
  return cmd
639
640
 
@@ -721,16 +722,21 @@ def sync(
721
722
  Sync(filename, extras, save, dry=dry).run()
722
723
 
723
724
 
724
- def _should_run_test_script(path: Path = Path("scripts/test.sh")) -> bool:
725
- return path.exists()
725
+ def _should_run_test_script(path: Path = Path("scripts")) -> Path | None:
726
+ for name in ("test.sh", "test.py"):
727
+ if (file := path / name).exists():
728
+ return file
729
+ return None
726
730
 
727
731
 
728
732
  def test(dry: bool, ignore_script=False) -> None:
729
733
  cwd = Path.cwd()
730
734
  root = Project.get_work_dir(cwd=cwd, allow_cwd=True)
731
- test_script = root / "scripts" / "test.sh"
732
- if not _ensure_bool(ignore_script) and _should_run_test_script(test_script):
733
- cmd = f"sh {os.path.relpath(test_script, root)}"
735
+ script_dir = root / "scripts"
736
+ if not _ensure_bool(ignore_script) and (
737
+ test_script := _should_run_test_script(script_dir)
738
+ ):
739
+ cmd = f"{os.path.relpath(test_script, root)}"
734
740
  if cwd != root:
735
741
  cmd = f"cd {root} && " + cmd
736
742
  else:
@@ -40,7 +40,7 @@ dependencies = [
40
40
  "bumpversion2 >=1.4.2,<2",
41
41
  "pytest >=8.2.0,<9",
42
42
  ]
43
- version = "0.10.0"
43
+ version = "0.10.1"
44
44
 
45
45
  [project.urls]
46
46
  Homepage = "https://github.com/waketzheng/fast-dev-cli"
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env python
2
+ import os
3
+ import sys
4
+
5
+ parent = os.path.abspath(os.path.dirname(__file__))
6
+ work_dir = os.path.dirname(parent)
7
+ if os.getcwd() != work_dir:
8
+ os.chdir(work_dir)
9
+
10
+ if os.system("pdm run fast check") != 0:
11
+ print("\033[1m Please run './scripts/format.py' to auto-fix style issues \033[0m")
12
+ sys.exit(1)
13
+
14
+ package_name = os.path.basename(work_dir).replace("-", "_")
15
+ cmd = "pdm run bandit -r {}".format(package_name)
16
+ print("-->", cmd)
17
+ if os.system(cmd) != 0:
18
+ sys.exit(1)
19
+ print("Done.")
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env python
2
+ import os
3
+ import shlex
4
+ import subprocess
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ work_dir = Path(__file__).parent.resolve().parent
9
+ if Path.cwd() != work_dir:
10
+ os.chdir(str(work_dir))
11
+
12
+ cmd = "pdm run fast lint"
13
+ r = subprocess.run(shlex.split(cmd), env=dict(os.environ, SKIP_MYPY="1"))
14
+ sys.exit(None if r.returncode == 0 else 1)
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env python
2
+ import os
3
+ import shlex
4
+ import subprocess
5
+ import sys
6
+ import time
7
+ from pathlib import Path
8
+
9
+ work_dir = Path(__file__).parent.resolve().parent
10
+ if Path.cwd() != work_dir:
11
+ os.chdir(str(work_dir))
12
+
13
+ CMD = "pdm run coverage run -m pytest"
14
+ COMBINE = "pdm run coverage combine .coverage*"
15
+ REPORT = "pdm run coverage report -m"
16
+
17
+
18
+ def remove_outdate_files(start_time: float) -> None:
19
+ for file in work_dir.glob(".coverage*"):
20
+ if file.stat().st_mtime < start_time:
21
+ file.unlink()
22
+ print(f"Removed outdate file: {file}")
23
+
24
+
25
+ def run_command(cmd: str, shell=False) -> None:
26
+ print("-->", cmd, flush=True)
27
+ r = subprocess.run(cmd if shell else shlex.split(cmd), shell=shell)
28
+ r.returncode and sys.exit(1)
29
+
30
+
31
+ def combine_result_files(shell=COMBINE) -> None:
32
+ to_be_combine = [i.name for i in work_dir.glob(".coverage.*")]
33
+ if to_be_combine:
34
+ if sys.platform == "win32":
35
+ if work_dir.joinpath(".coverage").exists():
36
+ shell = shell.replace("*", " ")
37
+ else:
38
+ shell = shell.replace(".coverage*", "")
39
+ shell += " ".join(to_be_combine)
40
+ run_command(shell, True)
41
+
42
+
43
+ started_at = time.time()
44
+ run_command(CMD)
45
+ remove_outdate_files(started_at)
46
+ combine_result_files()
47
+ run_command(REPORT)
@@ -1,5 +1,8 @@
1
+ import os
1
2
  import pathlib
3
+ from typing import Generator
2
4
 
5
+ import pytest
3
6
  from pytest_mock import MockerFixture
4
7
 
5
8
  from fast_dev_cli.cli import (
@@ -10,6 +13,15 @@ from fast_dev_cli.cli import (
10
13
  )
11
14
  from fast_dev_cli.cli import test as unitcase
12
15
 
16
+ TEST_SCRIPT = os.path.join("scripts", "test.py")
17
+
18
+
19
+ @pytest.fixture
20
+ def script_path() -> Generator[pathlib.Path, None, None]:
21
+ parent = pathlib.Path(__file__).parent
22
+ test_script = parent.resolve().parent / "scripts" / "test.py"
23
+ yield test_script
24
+
13
25
 
14
26
  def test_cli_test(mocker, capsys):
15
27
  output = capture_cmd_output("python fast_dev_cli/cli.py test --dry --ignore-script")
@@ -19,7 +31,7 @@ def test_cli_test(mocker, capsys):
19
31
  )
20
32
 
21
33
  mocker.patch("fast_dev_cli.cli.is_venv", return_value=True)
22
- mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=False)
34
+ mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=None)
23
35
  unitcase(dry=True)
24
36
  assert (
25
37
  'coverage run -m pytest -s && coverage report --omit="tests/*" -m'
@@ -29,7 +41,7 @@ def test_cli_test(mocker, capsys):
29
41
 
30
42
  def test_test_with_pdm_run(mocker: MockerFixture, capsys):
31
43
  mocker.patch("fast_dev_cli.cli.check_call", return_value=False)
32
- mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=False)
44
+ mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=None)
33
45
  unitcase(dry=True)
34
46
  assert (
35
47
  '--> pdm run coverage run -m pytest -s && pdm run coverage report --omit="tests/*" -m'
@@ -39,7 +51,7 @@ def test_test_with_pdm_run(mocker: MockerFixture, capsys):
39
51
 
40
52
  def test_test_with_poetry_or_pdm_run(mocker: MockerFixture, capsys):
41
53
  mocker.patch("fast_dev_cli.cli.check_call", return_value=False)
42
- mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=False)
54
+ mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=None)
43
55
  mocker.patch("fast_dev_cli.cli.Project.manage_by_poetry", return_value=True)
44
56
  unitcase(dry=True)
45
57
  command = "coverage"
@@ -52,7 +64,7 @@ def test_test_with_poetry_or_pdm_run(mocker: MockerFixture, capsys):
52
64
 
53
65
 
54
66
  def test_test_not_in_venv(mocker: MockerFixture, capsys):
55
- mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=False)
67
+ mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=None)
56
68
  mocker.patch("fast_dev_cli.cli.is_venv", return_value=False)
57
69
  unitcase(dry=True)
58
70
  command = "coverage"
@@ -64,26 +76,26 @@ def test_test_not_in_venv(mocker: MockerFixture, capsys):
64
76
  )
65
77
 
66
78
 
67
- def test_run_script(mocker: MockerFixture, capsys):
79
+ def test_run_script(mocker: MockerFixture, capsys, script_path):
68
80
  assert _should_run_test_script()
69
- mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=True)
81
+ mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=script_path)
70
82
  unitcase(dry=True)
71
- assert "sh scripts/test.sh" in capsys.readouterr().out
83
+ assert TEST_SCRIPT in capsys.readouterr().out
84
+ assert _should_run_test_script(pathlib.Path("not-exist")) is None
72
85
 
73
86
 
74
- def test_ignore_script(mocker: MockerFixture, capsys):
75
- mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=True)
87
+ def test_ignore_script(mocker: MockerFixture, capsys, script_path):
88
+ mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=script_path)
76
89
  unitcase(dry=True, ignore_script=True)
77
- assert "sh scripts/test.sh" not in capsys.readouterr().out
90
+ assert TEST_SCRIPT not in capsys.readouterr().out
78
91
 
79
92
 
80
- def test_run_script_in_sub_directory(mocker: MockerFixture, capsys):
81
- parent = pathlib.Path(__file__).parent
82
- mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=True)
83
- mocker.patch("pathlib.Path.cwd", return_value=parent)
93
+ def test_run_script_in_sub_directory(mocker: MockerFixture, capsys, script_path):
94
+ mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=script_path)
95
+ mocker.patch("pathlib.Path.cwd", return_value=script_path.parent)
84
96
  unitcase(dry=True)
85
97
  out = capsys.readouterr().out
86
- assert f"cd {parent.parent} && sh scripts/test.sh" in out
98
+ assert f"cd {script_path.parent.parent} && {TEST_SCRIPT}" in out
87
99
 
88
100
 
89
101
  def test_fast_test(mocker, capsys):
@@ -94,7 +106,7 @@ def test_fast_test(mocker, capsys):
94
106
  )
95
107
 
96
108
  mocker.patch("fast_dev_cli.cli.is_venv", return_value=True)
97
- mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=False)
109
+ mocker.patch("fast_dev_cli.cli._should_run_test_script", return_value=None)
98
110
  coverage_test(dry=True)
99
111
  assert (
100
112
  'coverage run -m pytest -s && coverage report --omit="tests/*" -m'
@@ -1,3 +1,4 @@
1
+ import shutil
1
2
  from pathlib import Path
2
3
 
3
4
  import pytest
@@ -10,6 +11,7 @@ from fast_dev_cli.cli import (
10
11
  lint,
11
12
  make_style,
12
13
  only_check,
14
+ run_and_echo,
13
15
  )
14
16
 
15
17
  from .utils import capture_stdout, chdir, mock_sys_argv
@@ -56,7 +58,7 @@ LINT_CMD = _CMD.format("", " --fix")
56
58
  CHECK_CMD = _CMD.format(" --check", "")
57
59
 
58
60
 
59
- def test_check(mock_no_dmypy, monkeypatch):
61
+ def test_check(mock_no_dmypy, monkeypatch, mocker):
60
62
  command = capture_cmd_output("fast check --dry")
61
63
  for cmd in CHECK_CMD.split(SEP):
62
64
  assert cmd in command
@@ -70,6 +72,16 @@ def test_check(mock_no_dmypy, monkeypatch):
70
72
  assert command4 == command
71
73
 
72
74
 
75
+ def test_check_bandit(tmp_path):
76
+ package_path = tmp_path / "foo"
77
+ with chdir(tmp_path):
78
+ run_and_echo(f"poetry new {package_path.name}")
79
+ shutil.rmtree(package_path / package_path.name)
80
+ with chdir(package_path):
81
+ command = capture_cmd_output("fast check --bandit --dry")
82
+ assert "bandit -r ." in command
83
+
84
+
73
85
  def test_fast_check():
74
86
  _fast_check()
75
87
 
@@ -155,7 +167,7 @@ def test_lint_func(mocker, mock_no_dmypy):
155
167
  with capture_stdout() as stream:
156
168
  lint(["lint"], dry=True)
157
169
  assert LINT_CMD in stream.getvalue()
158
- assert LINT_CMD in capture_cmd_output("python -m fast_dev_cli lint --dry")
170
+ assert LINT_CMD in capture_cmd_output("pdm run python -m fast_dev_cli lint --dry")
159
171
 
160
172
 
161
173
  def test_lint_without_ruff_installed(mocker, mock_no_dmypy):
@@ -0,0 +1,70 @@
1
+ import os
2
+ import shutil
3
+ import sys
4
+ from contextlib import contextmanager
5
+ from pathlib import Path
6
+ from typing import Generator
7
+
8
+ import pytest
9
+
10
+ from fast_dev_cli.cli import (
11
+ TOML_FILE,
12
+ BumpUp,
13
+ ParseError,
14
+ run_and_echo,
15
+ )
16
+
17
+ from .utils import chdir
18
+
19
+ CONF = """
20
+
21
+ [tool.poetry-version-plugin]
22
+ source = "init"
23
+ """
24
+
25
+
26
+ @contextmanager
27
+ def _prepare_package(
28
+ package_path: Path, define_include=False
29
+ ) -> Generator[Path, None, None]:
30
+ toml_file = package_path / TOML_FILE
31
+ package_name = package_path.name.replace(" ", "_")
32
+ init_file = package_path / package_name / "__init__.py"
33
+ a, b = 'version = "0.1.0"', 'version = "0"'
34
+ if define_include:
35
+ b += '\npackages = [{include = "%s"}]' % package_name
36
+ with chdir(package_path.parent):
37
+ run_and_echo(f'poetry new "{package_path.name}"')
38
+ toml_file.unlink()
39
+ py_version = "{0}.{1}".format(*sys.version_info)
40
+ with chdir(package_path):
41
+ run_and_echo(f'poetry init --python="^{py_version}" --no-interaction')
42
+ text = toml_file.read_text().replace(a, b)
43
+ toml_file.write_text(text + CONF)
44
+ shutil.move(package_path.name, package_name)
45
+ init_file.write_text('__version__ = "0.0.1"\n')
46
+ yield init_file
47
+
48
+
49
+ def _build_bump_cmd(init_file: Path) -> str:
50
+ relative_path = os.path.join(init_file.parent.name, init_file.name)
51
+ return rf'bumpversion --parse "(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)" --current-version="0.0.1" patch {relative_path} --allow-dirty'
52
+
53
+
54
+ def test_version_plugin(tmp_path: Path) -> None:
55
+ with _prepare_package(tmp_path / "helloworld") as init_file:
56
+ command = _build_bump_cmd(init_file)
57
+ assert BumpUp(part="patch", commit=False, dry=True).gen() == command
58
+ run_and_echo("poetry run fast bump patch")
59
+ assert init_file.read_text() == '__version__ = "0.0.2"\n'
60
+ init_file.unlink()
61
+ with pytest.raises(ParseError, match=r"Version file not found!.*"):
62
+ BumpUp(part="patch", commit=False, dry=True).gen()
63
+
64
+
65
+ def test_version_plugin_include_defined(tmp_path: Path) -> None:
66
+ with _prepare_package(tmp_path / "hello world", True) as init_file:
67
+ command = _build_bump_cmd(init_file)
68
+ assert BumpUp(part="patch", commit=False, dry=True).gen() == command
69
+ run_and_echo("poetry run fast bump patch")
70
+ assert init_file.read_text() == '__version__ = "0.0.2"\n'
@@ -1,3 +1,4 @@
1
+ import sys
1
2
  from contextlib import contextmanager
2
3
 
3
4
  from fast_dev_cli.cli import (
@@ -36,7 +37,12 @@ def test_echo_when_not_dry(mocker, capsys):
36
37
 
37
38
  @contextmanager
38
39
  def _clear_tags():
39
- run_and_echo("git tag | xargs git tag -d")
40
+ if sys.platform == "win32":
41
+ for t in capture_cmd_output("git tag").splitlines():
42
+ if "v" in (tag := t.strip()):
43
+ run_and_echo(f"git tag -d {tag}")
44
+ else:
45
+ run_and_echo("git tag | xargs git tag -d")
40
46
  yield
41
47
  run_and_echo("git pull --tags")
42
48
 
@@ -1 +0,0 @@
1
- __version__ = "0.10.0"
@@ -1,3 +0,0 @@
1
- from .cli import main
2
-
3
- main()
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -e
4
- set -x
5
-
6
- [ -f pyproject.toml ] || ([ -f ../pyproject.toml ] && cd ..)
7
-
8
- pdm run fast check || \
9
- echo -e "\033[1m Please run './scripts/format.sh' to auto-fix style issues \033[0m"
10
-
11
- pdm run bandit -r fast_dev_cli/
@@ -1,6 +0,0 @@
1
- #!/bin/sh -e
2
- set -x
3
-
4
- [ -f pyproject.toml ] || ([ -f ../pyproject.toml ] && cd ..)
5
-
6
- SKIP_MYPY=1 pdm run fast lint
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -e
4
- pdm run coverage run -m pytest
5
- pdm run coverage combine .coverage*
6
- pdm run coverage report -m
@@ -1,62 +0,0 @@
1
- from pathlib import Path
2
-
3
- import pytest
4
-
5
- from fast_dev_cli.cli import (
6
- TOML_FILE,
7
- BumpUp,
8
- ParseError,
9
- run_and_echo,
10
- )
11
-
12
- from .utils import chdir
13
-
14
- CONF = """
15
-
16
- [tool.poetry-version-plugin]
17
- source = "init"
18
- """
19
-
20
-
21
- def test_version_plugin(tmp_path: Path) -> None:
22
- package_path = tmp_path / "helloworld"
23
- toml_file = package_path / TOML_FILE
24
- init_file = package_path / package_path.name / "__init__.py"
25
- a, b = 'version = "0.1.0"', 'version = "0"'
26
- with chdir(tmp_path):
27
- run_and_echo(f"poetry new {package_path.name}")
28
- with chdir(package_path):
29
- text = toml_file.read_text().replace(a, b)
30
- toml_file.write_text(text + CONF)
31
- init_file.write_text('__version__ = "0.0.1"\n')
32
- assert (
33
- BumpUp(part="patch", commit=False, dry=True).gen()
34
- == 'bumpversion --parse "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)" --current-version="0.0.1" patch helloworld/__init__.py --allow-dirty'
35
- )
36
- run_and_echo("poetry run fast bump patch")
37
- assert init_file.read_text() == '__version__ = "0.0.2"\n'
38
- init_file.unlink()
39
- with pytest.raises(ParseError, match=r"Version file not found!.*"):
40
- BumpUp(part="patch", commit=False, dry=True).gen()
41
-
42
-
43
- def test_version_plugin_include_defined(tmp_path: Path) -> None:
44
- package_path = tmp_path / "hello world"
45
- toml_file = package_path / TOML_FILE
46
- package_name = package_path.name.replace(" ", "_")
47
- init_file = package_path / package_name / "__init__.py"
48
- a, b = 'version = "0.1.0"', 'version = "0"'
49
- b += '\npackages = [{include = "%s"}]' % package_name
50
- with chdir(tmp_path):
51
- run_and_echo(f"poetry new '{package_path.name}'")
52
- with chdir(package_path):
53
- text = toml_file.read_text().replace(a, b)
54
- toml_file.write_text(text + CONF)
55
- run_and_echo(f"mv '{package_path.name}' {package_name}")
56
- init_file.write_text('__version__ = "0.0.1"\n')
57
- assert (
58
- BumpUp(part="patch", commit=False, dry=True).gen()
59
- == f'bumpversion --parse "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)" --current-version="0.0.1" patch {package_name}/__init__.py --allow-dirty'
60
- )
61
- run_and_echo("poetry run fast bump patch")
62
- assert init_file.read_text() == '__version__ = "0.0.2"\n'
File without changes