Skip to content
This repository was archived by the owner on Mar 11, 2023. It is now read-only.

Commit 4739fd3

Browse files
authored
Merge branch 'master' into fix46
2 parents 48d1698 + d85a42c commit 4739fd3

7 files changed

Lines changed: 200 additions & 49 deletions

File tree

requirements-dev.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pytest
2+
coverage
3+
polib
4+
tox
5+
flake8
6+
mypy
7+
black

requirements-dev.txt

Lines changed: 86 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,87 @@
1+
#
2+
# This file is autogenerated by pip-compile
3+
# To update, run:
4+
#
5+
# pip-compile requirements-dev.in
6+
#
7+
appdirs==1.4.4
8+
# via
9+
# black
10+
# virtualenv
11+
attrs==20.3.0
12+
# via pytest
13+
black==20.8b1
14+
# via -r requirements-dev.in
15+
click==7.1.2
16+
# via black
17+
coverage==5.3.1
18+
# via pytest-cov
19+
distlib==0.3.1
20+
# via virtualenv
21+
filelock==3.0.12
22+
# via
23+
# tox
24+
# virtualenv
25+
flake8==3.8.4
26+
# via -r requirements-dev.in
27+
iniconfig==1.1.1
28+
# via pytest
29+
mccabe==0.6.1
30+
# via flake8
31+
mypy-extensions==0.4.3
32+
# via
33+
# black
34+
# mypy
35+
mypy==0.790
36+
# via -r requirements-dev.in
37+
packaging==20.8
38+
# via
39+
# pytest
40+
# tox
41+
pathspec==0.8.1
42+
# via black
43+
pluggy==0.13.1
44+
# via
45+
# pytest
46+
# tox
147
polib==1.1.0
2-
requests==2.25.0
3-
simple-term-menu==0.10.4
4-
gitignore_parser==0.0.8
5-
tox
6-
virtualenv
7-
flake8
8-
mypy
9-
black
48+
# via -r requirements-dev.in
49+
py==1.10.0
50+
# via
51+
# pytest
52+
# tox
53+
pycodestyle==2.6.0
54+
# via flake8
55+
pyflakes==2.2.0
56+
# via flake8
57+
pyparsing==2.4.7
58+
# via packaging
59+
pytest-cov==2.10.1
60+
# via -r requirements-dev.in
61+
pytest==6.2.1
62+
# via
63+
# -r requirements-dev.in
64+
# pytest-cov
65+
regex==2020.11.13
66+
# via black
67+
six==1.15.0
68+
# via
69+
# tox
70+
# virtualenv
71+
toml==0.10.2
72+
# via
73+
# black
74+
# pytest
75+
# tox
76+
tox==3.20.1
77+
# via -r requirements-dev.in
78+
typed-ast==1.4.2
79+
# via
80+
# black
81+
# mypy
82+
typing-extensions==3.7.4.3
83+
# via
84+
# black
85+
# mypy
86+
virtualenv==20.2.2
87+
# via tox

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
polib==1.1.0
22
requests==2.25.0
33
simple-term-menu==0.10.4
4-
gitignore_parser==0.0.8
4+
gitignore-parser==0.0.8

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package_dir={"potodo": "potodo"},
2121
entry_points={"console_scripts": ["potodo=potodo.potodo:main"]},
2222
include_package_data=True,
23-
install_requires=["polib", "requests", "simple-term-menu", "gitignore_parser"],
23+
install_requires=["polib", "requests", "simple-term-menu", "gitignore-parser"],
2424
license="MIT license",
2525
zip_safe=False,
2626
keywords="potodo",

tests/test_potodo_args_errors.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import sys
12
from pathlib import Path
2-
33
from subprocess import check_output, CalledProcessError
44

55
REPO_DIR = "repository"
@@ -29,31 +29,41 @@ class TestPotodoArgsErrors:
2929
excluded_2 = str(config["exclude"][1])
3030

3131
def test_potodo_help(self):
32-
output = check_output(["potodo", "--help"]).decode("utf-8")
33-
output_short = check_output(["potodo", "-h"]).decode("utf-8")
32+
output = check_output([sys.executable, "-m", "potodo", "--help"]).decode(
33+
"utf-8"
34+
)
35+
output_short = check_output([sys.executable, "-m", "potodo", "-h"]).decode(
36+
"utf-8"
37+
)
3438
assert output == output_short
3539
assert "-h, --help show this help message and exit" in output
3640
# TODO: Find a better way of testing help output
3741

3842
def test_potodo_above_below_conflict(self):
3943
try:
40-
check_output(["potodo", "--above", "50", "--below", "40"]).decode("utf-8")
44+
check_output(
45+
[sys.executable, "-m", "potodo", "--above", "50", "--below", "40"]
46+
).decode("utf-8")
4147
except CalledProcessError as e:
4248
output = e.output
4349
try:
44-
check_output(["potodo", "-a", "50", "-b", "40"]).decode("utf-8")
50+
check_output(
51+
[sys.executable, "-m", "potodo", "-a", "50", "-b", "40"]
52+
).decode("utf-8")
4553
except CalledProcessError as e:
4654
output_short = e.output
4755
assert output == output_short
4856
assert output == b"Potodo: 'below' value must be greater than 'above' value.\n"
4957

5058
def test_potodo_json_interactive_conflict(self):
5159
try:
52-
check_output(["potodo", "--json", "--interactive"]).decode("utf-8")
60+
check_output(
61+
[sys.executable, "-m", "potodo", "--json", "--interactive"]
62+
).decode("utf-8")
5363
except CalledProcessError as e:
5464
output = e.output
5565
try:
56-
check_output(["potodo", "-j", "-i"]).decode("utf-8")
66+
check_output([sys.executable, "-m", "potodo", "-j", "-i"]).decode("utf-8")
5767
except CalledProcessError as e:
5868
output_short = e.output
5969
assert output == output_short
@@ -64,7 +74,9 @@ def test_potodo_json_interactive_conflict(self):
6474

6575
def test_potodo_exclude_and_only_fuzzy_conflict(self):
6676
try:
67-
check_output(["potodo", "--exclude-fuzzy", "--only-fuzzy"]).decode("utf-8")
77+
check_output(
78+
[sys.executable, "-m", "potodo", "--exclude-fuzzy", "--only-fuzzy"]
79+
).decode("utf-8")
6880
except CalledProcessError as e:
6981
output = e.output
7082
assert (
@@ -74,9 +86,15 @@ def test_potodo_exclude_and_only_fuzzy_conflict(self):
7486

7587
def test_potodo_exclude_and_only_reserved_conflict(self):
7688
try:
77-
check_output(["potodo", "--exclude-reserved", "--only-reserved"]).decode(
78-
"utf-8"
79-
)
89+
check_output(
90+
[
91+
sys.executable,
92+
"-m",
93+
"potodo",
94+
"--exclude-reserved",
95+
"--only-reserved",
96+
]
97+
).decode("utf-8")
8098
except CalledProcessError as e:
8199
output = e.output
82100
assert (

tests/test_potodo_default_args.py

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import sys
12
from pathlib import Path
2-
33
from subprocess import check_output
44

55
REPO_DIR = "repository"
@@ -29,7 +29,7 @@ class TestPotodoCLI:
2929
excluded_2 = str(config["exclude"][1])
3030

3131
def test_potodo_no_args(self):
32-
output = check_output("potodo").decode("utf-8")
32+
output = check_output([sys.executable, "-m", "potodo"]).decode("utf-8")
3333
assert "# excluded 1 / 2 (50.00% translated)" in output
3434
assert "# folder 1 / 3 (33.33% translated)" in output
3535
assert (
@@ -46,10 +46,17 @@ def test_potodo_no_args(self):
4646

4747
def test_potodo_exclude(self):
4848
output = check_output(
49-
["potodo", "--exclude", self.excluded_1, self.excluded_2]
49+
[
50+
sys.executable,
51+
"-m",
52+
"potodo",
53+
"--exclude",
54+
self.excluded_1,
55+
self.excluded_2,
56+
]
5057
).decode("utf-8")
5158
output_short = check_output(
52-
["potodo", "-e", self.excluded_1, self.excluded_2]
59+
[sys.executable, "-m", "potodo", "-e", self.excluded_1, self.excluded_2]
5360
).decode("utf-8")
5461
assert output == output_short
5562
assert "# excluded 1 / 2 (50.00% translated)" in output
@@ -64,8 +71,12 @@ def test_potodo_exclude(self):
6471
)
6572

6673
def test_potodo_above(self):
67-
output = check_output(["potodo", "--above", "40"]).decode("utf-8")
68-
output_short = check_output(["potodo", "-a", "40"]).decode("utf-8")
74+
output = check_output([sys.executable, "-m", "potodo", "--above", "40"]).decode(
75+
"utf-8"
76+
)
77+
output_short = check_output(
78+
[sys.executable, "-m", "potodo", "-a", "40"]
79+
).decode("utf-8")
6980
assert output == output_short
7081
assert (
7182
"- file1.po 1 / 3 ( 33.0% translated), 1 fuzzy"
@@ -76,8 +87,12 @@ def test_potodo_above(self):
7687
)
7788

7889
def test_potodo_below(self):
79-
output = check_output(["potodo", "--below", "40"]).decode("utf-8")
80-
output_short = check_output(["potodo", "-b", "40"]).decode("utf-8")
90+
output = check_output([sys.executable, "-m", "potodo", "--below", "40"]).decode(
91+
"utf-8"
92+
)
93+
output_short = check_output(
94+
[sys.executable, "-m", "potodo", "-b", "40"]
95+
).decode("utf-8")
8196
assert output == output_short
8297
assert (
8398
"- file1.po 1 / 3 ( 33.0% translated), 1 fuzzy"
@@ -89,8 +104,12 @@ def test_potodo_below(self):
89104
)
90105

91106
def test_potodo_onlyfuzzy(self):
92-
output = check_output(["potodo", "--only-fuzzy"]).decode("utf-8")
93-
output_short = check_output(["potodo", "-f"]).decode("utf-8")
107+
output = check_output([sys.executable, "-m", "potodo", "--only-fuzzy"]).decode(
108+
"utf-8"
109+
)
110+
output_short = check_output([sys.executable, "-m", "potodo", "-f"]).decode(
111+
"utf-8"
112+
)
94113
assert output == output_short
95114
assert (
96115
"- file1.po 1 / 3 ( 33.0% translated), 1 fuzzy"
@@ -102,8 +121,12 @@ def test_potodo_onlyfuzzy(self):
102121
)
103122

104123
def test_potodo_counts(self):
105-
output = check_output(["potodo", "--counts"]).decode("utf-8")
106-
output_short = check_output(["potodo", "-c"]).decode("utf-8")
124+
output = check_output([sys.executable, "-m", "potodo", "--counts"]).decode(
125+
"utf-8"
126+
)
127+
output_short = check_output([sys.executable, "-m", "potodo", "-c"]).decode(
128+
"utf-8"
129+
)
107130
assert output == output_short
108131
assert (
109132
"- excluded.po 1 / 2 ( 50.0% translated)"
@@ -116,7 +139,9 @@ def test_potodo_counts(self):
116139
)
117140

118141
def test_potodo_exclude_fuzzy(self):
119-
output = check_output(["potodo", "--exclude-fuzzy"]).decode("utf-8")
142+
output = check_output(
143+
[sys.executable, "-m", "potodo", "--exclude-fuzzy"]
144+
).decode("utf-8")
120145
assert (
121146
"- excluded.po 1 / 2 ( 50.0% translated)" in output
122147
)
@@ -126,8 +151,12 @@ def test_potodo_exclude_fuzzy(self):
126151
)
127152

128153
def test_potodo_matching_files_solo(self):
129-
output = check_output(["potodo", "--matching-files"]).decode("utf-8")
130-
output_short = check_output(["potodo", "-l"]).decode("utf-8")
154+
output = check_output(
155+
[sys.executable, "-m", "potodo", "--matching-files"]
156+
).decode("utf-8")
157+
output_short = check_output([sys.executable, "-m", "potodo", "-l"]).decode(
158+
"utf-8"
159+
)
131160
assert output == output_short
132161
assert "excluded/file4.po" in output
133162
assert "folder/excluded.po" in output
@@ -136,10 +165,12 @@ def test_potodo_matching_files_solo(self):
136165
assert "file2.po" in output
137166

138167
def test_potodo_matching_files_fuzzy(self):
139-
output = check_output(["potodo", "--matching-files", "--only-fuzzy"]).decode(
140-
"utf-8"
141-
)
142-
output_short = check_output(["potodo", "-l", "-f"]).decode("utf-8")
168+
output = check_output(
169+
[sys.executable, "-m", "potodo", "--matching-files", "--only-fuzzy"]
170+
).decode("utf-8")
171+
output_short = check_output(
172+
[sys.executable, "-m", "potodo", "-l", "-f"]
173+
).decode("utf-8")
143174
assert output == output_short
144175
assert "file1.po" in output
145176

tox.ini

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,43 @@
11
[flake8]
22
extend-ignore = E501 # line length handled by black.
33

4+
[coverage:run]
5+
branch = true
6+
parallel = true
7+
omit =
8+
.tox/*
9+
10+
[coverage:report]
11+
skip_covered = True
12+
show_missing = True
13+
414
[tox]
5-
envlist = py36, py37, py38, py39, flake8, mypy, black
15+
envlist = py36, py37, py38, py39, flake8, mypy, black, coverage
616
skip_missing_interpreters = True
717

818
[testenv]
9-
deps =
10-
pytest
11-
pytest-cov
19+
deps = -r requirements-dev.txt
20+
commands = coverage run -m pytest
21+
setenv =
22+
COVERAGE_FILE={toxworkdir}/.coverage.{envname}
23+
24+
[testenv:coverage]
25+
depends = py36, py37, py38, py39
26+
parallel_show_output = True
27+
skip_install = True
28+
setenv = COVERAGE_FILE={toxworkdir}/.coverage
1229
commands =
13-
pip install -e .
14-
pytest --cov=potodo tests/
30+
coverage combine
31+
coverage report --fail-under 60
1532

1633
[testenv:flake8]
17-
deps = flake8
34+
skip_install = True
1835
commands = flake8 tests/ potodo/
1936

2037
[testenv:black]
21-
deps = black
38+
skip_install = True
2239
commands = black --check --diff tests/ potodo/
2340

2441
[testenv:mypy]
25-
deps = mypy
42+
skip_install = True
2643
commands = mypy --ignore-missing-imports --strict potodo/

0 commit comments

Comments
 (0)