Skip to content

Commit 9e598bd

Browse files
committed
More updates for #408 and #399
1 parent feb7db5 commit 9e598bd

File tree

3 files changed

+23
-36
lines changed

3 files changed

+23
-36
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ invoke livehtml
265265
```
266266

267267
You will be shown the IP address and port number where the documents are now
268-
served. Put that into your web browser and edit away.
268+
served (usually [http://localhost:8000](http://localhost:8000).
269269

270270
### Static Code Analysis
271271

@@ -281,15 +281,8 @@ invoke pytest
281281
```
282282
and ensure all tests pass.
283283

284-
#### Measuring code coverage
285-
286-
Code coverage can be measured as follows:
287-
288-
```shell
289-
py.test --cov=cmd2 --cov-report=term-missing --cov-report=html
290-
```
291-
292-
Then use your web browser of choice to look at the results which are in `<cmd2>/htmlcov/index.html`.
284+
Running the test suite also calculates test code coverage. A summary of coverage
285+
is shown on the screen. A full report is available in `<cmd2>/htmlcov/index.html`.
293286

294287
### Squash Your Commits
295288
When you make a pull request, it is preferable for all of your changes to be in one commit.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
# install with 'pip install -e .[dev]'
7474
'dev': [
7575
'pytest', 'pytest-cov', 'tox', 'pylint', 'sphinx', 'sphinx-rtd-theme',
76-
'sphinx-autobuild','invoke',
76+
'sphinx-autobuild','invoke', 'twine',
7777
]
7878
}
7979

tasks.py

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@
88
import invoke
99

1010
# shared function
11-
def rmrf(dirs, verbose=True):
12-
"Silently remove a list of directories"
13-
if isinstance(dirs, str):
14-
dirs = [dirs]
11+
def rmrf(items, verbose=True):
12+
"Silently remove a list of directories or files"
13+
if isinstance(items, str):
14+
items = [items]
1515

16-
for dir_ in dirs:
16+
for item in items:
1717
if verbose:
18-
print("Removing {}".format(dir_))
19-
shutil.rmtree(dir_, ignore_errors=True)
18+
print("Removing {}".format(item))
19+
shutil.rmtree(item, ignore_errors=True)
20+
# rmtree doesn't remove bare files
21+
try:
22+
os.remove(item)
23+
except FileNotFoundError:
24+
pass
2025

2126

2227
# create namespaces
@@ -32,14 +37,14 @@ def rmrf(dirs, verbose=True):
3237
@invoke.task
3338
def pytest(context):
3439
"Run tests and code coverage using pytest"
35-
context.run("pytest --cov=cmd2 --cov-report=html")
40+
context.run("pytest --cov=cmd2 --cov-report=term --cov-report=html")
3641
namespace.add_task(pytest)
3742

3843
@invoke.task
3944
def pytest_clean(context):
40-
"Remove pytest cache directories"
45+
"Remove pytest cache and code coverage files and directories"
4146
#pylint: disable=unused-argument
42-
dirs = ['.pytest-cache', '.cache', 'htmlcov']
47+
dirs = ['.pytest-cache', '.cache', 'htmlcov', '.coverage']
4348
rmrf(dirs)
4449
namespace_clean.add_task(pytest_clean, 'pytest')
4550

@@ -56,17 +61,6 @@ def tox_clean(context):
5661
rmrf('.tox')
5762
namespace_clean.add_task(tox_clean, 'tox')
5863

59-
@invoke.task
60-
def codecov_clean(context):
61-
"Remove code coverage reports"
62-
#pylint: disable=unused-argument
63-
dirs = set()
64-
for name in os.listdir(os.curdir):
65-
if name.startswith('.coverage'):
66-
dirs.add(name)
67-
rmrf(dirs)
68-
namespace_clean.add_task(codecov_clean, 'coverage')
69-
7064

7165
#####
7266
#
@@ -158,25 +152,25 @@ def clean_all(context):
158152
pass
159153
namespace_clean.add_task(clean_all, 'all')
160154

161-
@invoke.task
155+
@invoke.task(pre=[clean_all])
162156
def sdist(context):
163157
"Create a source distribution"
164158
context.run('python setup.py sdist')
165159
namespace.add_task(sdist)
166160

167-
@invoke.task
161+
@invoke.task(pre=[clean_all])
168162
def wheel(context):
169163
"Build a wheel distribution"
170164
context.run('python setup.py bdist_wheel')
171165
namespace.add_task(wheel)
172166

173-
@invoke.task(pre=[clean_all, sdist, wheel])
167+
@invoke.task(pre=[sdist, wheel])
174168
def pypi(context):
175169
"Build and upload a distribution to pypi"
176170
context.run('twine upload dist/*')
177171
namespace.add_task(pypi)
178172

179-
@invoke.task(pre=[clean_all, sdist, wheel])
173+
@invoke.task(pre=[sdist, wheel])
180174
def pypi_test(context):
181175
"Build and upload a distribution to https://test.pypi.org"
182176
context.run('twine upload --repository-url https://test.pypi.org/legacy/ dist/*')

0 commit comments

Comments
 (0)