Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
1cbdf581
Commit
1cbdf581
authored
Jan 01, 2015
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace setup and teardown with pytest fixtures.
parent
ae700746
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
33 deletions
+29
-33
setuptools/tests/test_bdist_egg.py
setuptools/tests/test_bdist_egg.py
+29
-33
No files found.
setuptools/tests/test_bdist_egg.py
View file @
1cbdf581
...
...
@@ -2,10 +2,9 @@
"""
import
os
import
re
import
shutil
import
site
import
tempfile
import
unittest
import
pytest
import
mock
from
setuptools.dist
import
Distribution
...
...
@@ -18,30 +17,31 @@ from setuptools import setup
setup(name='foo', py_modules=['hi'])
"""
class
TestDevelopTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
dir
=
tempfile
.
mkdtemp
()
self
.
old_cwd
=
os
.
getcwd
()
os
.
chdir
(
self
.
dir
)
with
open
(
'setup.py'
,
'w'
)
as
f
:
f
.
write
(
SETUP_PY
)
with
open
(
'hi.py'
,
'w'
)
as
f
:
f
.
write
(
'1
\
n
'
)
self
.
old_base
=
site
.
USER_BASE
site
.
USER_BASE
=
tempfile
.
mkdtemp
()
self
.
old_site
=
site
.
USER_SITE
site
.
USER_SITE
=
tempfile
.
mkdtemp
()
def
tearDown
(
self
):
os
.
chdir
(
self
.
old_cwd
)
shutil
.
rmtree
(
self
.
dir
)
shutil
.
rmtree
(
site
.
USER_BASE
)
shutil
.
rmtree
(
site
.
USER_SITE
)
site
.
USER_BASE
=
self
.
old_base
site
.
USER_SITE
=
self
.
old_site
def
test_bdist_egg
(
self
):
@
pytest
.
yield_fixture
def
user_override
():
"""
Override site.USER_BASE and site.USER_SITE with temporary directories in
a context.
"""
with
contexts
.
tempdir
()
as
user_base
:
with
mock
.
patch
(
'site.USER_BASE'
,
user_base
):
with
contexts
.
tempdir
()
as
user_site
:
with
mock
.
patch
(
'site.USER_SITE'
,
user_site
):
yield
@
pytest
.
yield_fixture
def
setup_context
(
tmpdir
):
with
(
tmpdir
/
'setup.py'
).
open
(
'w'
)
as
f
:
f
.
write
(
SETUP_PY
)
with
(
tmpdir
/
'hi.py'
).
open
(
'w'
)
as
f
:
f
.
write
(
'1
\
n
'
)
with
tmpdir
.
as_cwd
():
yield
tmpdir
class
TestDevelopTest
:
def
test_bdist_egg
(
self
,
setup_context
,
user_override
):
dist
=
Distribution
(
dict
(
script_name
=
'setup.py'
,
script_args
=
[
'bdist_egg'
],
...
...
@@ -55,8 +55,4 @@ class TestDevelopTest(unittest.TestCase):
# let's see if we got our egg link at the right place
[
content
]
=
os
.
listdir
(
'dist'
)
self
.
assertTrue
(
re
.
match
(
'foo-0.0.0-py[23].
\
d.egg$
'
, content))
def test_suite():
return unittest.makeSuite(TestDevelopTest)
assert
re
.
match
(
'foo-0.0.0-py[23].
\
d.egg$
'
, content)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment