Skip to content

Commit cc4252f

Browse files
committed
Merge branch pipenv. Close #13.
2 parents 7fa2f36 + 3a48a8b commit cc4252f

File tree

5 files changed

+55
-12
lines changed

5 files changed

+55
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*~
33
.cache/
44
__pycache__/
5+
/.gitrevision
56
/MANIFEST
67
/build/
78
/dist/

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141

4242
+ PR #11: show the name of the skipped test (thanks asteriogonzalez).
4343

44+
+ Issue #13: Do not import pytest in setup.py to make it compatible
45+
with pipenv.
46+
4447
* Version 0.2 (2017-05-28)
4548

4649
** New features

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build:
88
test: build
99
PYTHONPATH=$(BUILDDIR)/lib $(PYTHON) -m pytest tests
1010

11-
sdist: python2_6.patch doc-html
11+
sdist: python2_6.patch .gitrevision doc-html
1212
$(PYTHON) setup.py sdist
1313

1414
doc-html:
@@ -37,9 +37,11 @@ distclean: clean
3737
rm -f python2_6.patch
3838
$(MAKE) -C doc distclean
3939

40+
.gitrevision:
41+
git describe --always --dirty > .gitrevision
4042

4143
python2_6.patch:
4244
git diff `git merge-base master python2_6` python2_6 > $@
4345

4446

45-
.PHONY: build test sdist doc-html doc-pdf doc-dist clean distclean
47+
.PHONY: build test sdist doc-html doc-pdf doc-dist clean distclean .gitrevision

pytest_dependency.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
"""pytest-dependency - Manage dependencies of tests
1+
"""$DOC"""
22

3-
This pytest plugin manages dependencies of tests. It allows to mark
4-
some tests as dependent from other tests. These tests will then be
5-
skipped if any of the dependencies did fail or has been skipped.
6-
"""
3+
__version__ = "$VERSION"
4+
__revision__ = "$REVISION"
75

86
import pytest
97

10-
__version__ = "0.2"
11-
128

139
class DependencyItemStatus(object):
1410
"""Status of a test item in a dependency manager.

setup.py

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,65 @@
11
#! /usr/bin/python
2+
"""pytest-dependency - Manage dependencies of tests
3+
4+
This pytest plugin manages dependencies of tests. It allows to mark
5+
some tests as dependent from other tests. These tests will then be
6+
skipped if any of the dependencies did fail or has been skipped.
7+
"""
8+
9+
__version__ = "0.2"
210

311
import sys
412
if sys.version_info < (2, 7):
513
raise RuntimeError("You are using Python %s.\n"
614
"Please apply python2_6.patch first."
715
% sys.version.split()[0])
16+
import os
17+
import os.path
18+
import re
819
from setuptools import setup
9-
import pytest_dependency
20+
import setuptools.command.sdist as st_sdist
21+
22+
23+
def _filter_file(src, dest, subst):
24+
"""Copy src to dest doing substitutions on the fly.
25+
"""
26+
substre = re.compile(r'\$(%s)' % '|'.join(subst.keys()))
27+
def repl(m):
28+
return subst[m.group(1)]
29+
with open(src, "rt") as sf, open(dest, "wt") as df:
30+
while True:
31+
l = sf.readline()
32+
if not l:
33+
break
34+
df.write(re.sub(substre, repl, l))
35+
36+
class sdist(st_sdist.sdist):
37+
def make_release_tree(self, base_dir, files):
38+
st_sdist.sdist.make_release_tree(self, base_dir, files)
39+
if not self.dry_run:
40+
src = "pytest_dependency.py"
41+
dest = os.path.join(base_dir, src)
42+
gitrevfile = ".gitrevision"
43+
if hasattr(os, 'link') and os.path.exists(dest):
44+
os.unlink(dest)
45+
subst = {'DOC': __doc__, 'VERSION': __version__}
46+
if os.path.exists(gitrevfile):
47+
with open(gitrevfile, "rt") as f:
48+
subst['REVISION'] = f.readline().strip()
49+
_filter_file(src, dest, subst)
1050

1151

1252
setup(
1353
name='pytest-dependency',
14-
version=pytest_dependency.__version__,
54+
version=__version__,
1555
description='Manage dependencies of tests',
1656
author='Rolf Krahl',
1757
author_email='[email protected]',
1858
maintainer='Rolf Krahl',
1959
maintainer_email='[email protected]',
2060
url='https://github.com/RKrahl/pytest-dependency',
2161
license='Apache Software License 2.0',
22-
long_description=pytest_dependency.__doc__,
62+
long_description=__doc__,
2363
py_modules=['pytest_dependency'],
2464
install_requires=['pytest >= 2.8.0'],
2565
classifiers=[
@@ -46,4 +86,5 @@
4686
'dependency = pytest_dependency',
4787
],
4888
},
89+
cmdclass = {'sdist': sdist},
4990
)

0 commit comments

Comments
 (0)