Skip to content

Commit b5df54a

Browse files
authored
Merge pull request #84 from abstractfactory/master
AppVeyor support
2 parents 9acdbd1 + 53cb91f commit b5df54a

File tree

4 files changed

+94
-53
lines changed

4 files changed

+94
-53
lines changed

appveyor.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
build: false
2+
3+
environment:
4+
matrix:
5+
- PYTHON: "C:\\Python27-x64"
6+
PYQT: "http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.4/PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x64.exe"
7+
8+
# - PYTHON: "C:\\Python34-x64"
9+
# PYQT: "http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.4/PyQt4-4.11.4-gpl-Py3.4-Qt4.8.7-x64.exe"
10+
11+
init:
12+
- ECHO %PYTHON%
13+
- SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%
14+
15+
install:
16+
# Install PySide
17+
- python -m pip install nose nosepipe PySide
18+
19+
# Install PyQt4
20+
# miniconda (provided by AppVeyor) prevents PyQt installer
21+
# to run because of a registry key. So the line below overwrite
22+
# the registry key.
23+
24+
- REG ADD HKCU\Software\Python\PythonCore\2.7\InstallPath /f /ve /t REG_SZ /d %PYTHON%
25+
- ps: (new-object net.webclient).DownloadFile($env:PYQT, "C:\install-PyQt4.exe")
26+
- ps: Start-Process -FilePath C:\install-PyQt4.exe -ArgumentList "/S" -Wait -Passthru
27+
28+
# Test install
29+
- python -c "from PyQt4 import QtGui"
30+
- python -c "from PySide import QtGui"
31+
32+
test_script:
33+
- python build_caveats_tests.py
34+
- nosetests --verbose --with-doctest --with-process-isolation --exe

build_caveats_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python
2-
import parser
2+
import caveats
33

4-
blocks = parser.parse("CAVEATS.md")
5-
tests = parser.format_(blocks)
4+
blocks = caveats.parse("CAVEATS.md")
5+
tests = caveats.format_(blocks)
66

77
# Write formatted tests
88
with open("test_caveats.py", "w") as f:

parser.py renamed to caveats.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def parse(fname):
2121
# Doctests are within a quadruple hashtag header.
2222
if line.startswith("#### "):
2323
current_header = line.rstrip()
24-
24+
2525
# The actuat test is within a fenced block.
2626
if line.startswith("```"):
2727
in_block = False
@@ -38,9 +38,9 @@ def parse(fname):
3838
tests = list()
3939
for block in blocks:
4040
header = (
41-
block[0].strip("# ") # Remove Markdown
42-
.rstrip() # Remove newline
43-
.lower() # PEP08
41+
block[0].strip("# ") # Remove Markdown
42+
.rstrip() # Remove newline
43+
.lower() # PEP08
4444
)
4545

4646
# Remove unsupported characters
@@ -59,7 +59,7 @@ def parse(fname):
5959
)
6060

6161
binding, doctest_version = (data + [None])[:2]
62-
62+
6363
# Run tests on both Python 2 and 3, unless explicitly stated
6464
if doctest_version is not None:
6565
if doctest_version not in ("Python2", "Python3"):
@@ -83,7 +83,7 @@ def parse(fname):
8383

8484
def format_(blocks):
8585
"""Produce Python module from blocks of tests
86-
86+
8787
Arguments:
8888
blocks (list): Blocks of tests from func:`parse()`
8989
@@ -122,5 +122,5 @@ def test_{count}_{header}():
122122
'''
123123
124124
""".format(**block))
125-
125+
126126
return tests

tests.py

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919

2020
PYTHON = sys.version_info[0] # e.g. 2 or 3
2121

22+
self = sys.modules[__name__]
23+
24+
25+
def setup():
26+
self.tempdir = tempfile.mkdtemp()
27+
28+
29+
def teardown():
30+
shutil.rmtree(self.tempdir)
31+
2232

2333
@contextlib.contextmanager
2434
def pyqt4():
@@ -123,53 +133,50 @@ def test_vendoring():
123133
124134
project/
125135
vendor/
126-
__init__.py
127136
__init__.py
137+
__init__.py
128138
129139
"""
130140

131-
dirname = os.path.dirname(__file__)
132-
tempdir = tempfile.mkdtemp()
133-
134-
try:
135-
project = os.path.join(tempdir, "myproject")
136-
vendor = os.path.join(tempdir, "myproject", "vendor")
137-
138-
os.makedirs(vendor)
139-
140-
# Make packages out of folders
141-
with open(os.path.join(project, "__init__.py"), "w") as f:
142-
f.write("from .vendor.Qt import QtWidgets")
143-
144-
with open(os.path.join(vendor, "__init__.py"), "w") as f:
145-
pass
146-
147-
shutil.copy(os.path.join(dirname, "Qt.py"),
148-
os.path.join(vendor, "Qt.py"))
149-
150-
print("Testing relative import..")
151-
assert subprocess.call(
152-
["python", "-c", "import myproject"],
153-
cwd=tempdir,
154-
env={}
155-
) == 0
156-
157-
print("Testing absolute import..")
158-
assert subprocess.call(
159-
["python", "-c", "from myproject.vendor.Qt import QtWidgets"],
160-
cwd=tempdir,
161-
env={}
162-
) == 0
163-
164-
print("Testing direct import..")
165-
assert subprocess.call(
166-
["python", "-c", "import myproject.vendor.Qt"],
167-
cwd=tempdir,
168-
env={}
169-
) == 0
170-
171-
finally:
172-
shutil.rmtree(tempdir)
141+
project = os.path.join(self.tempdir, "myproject")
142+
vendor = os.path.join(project, "vendor")
143+
144+
os.makedirs(vendor)
145+
146+
# Make packages out of folders
147+
with open(os.path.join(project, "__init__.py"), "w") as f:
148+
f.write("from .vendor.Qt import QtWidgets")
149+
150+
with open(os.path.join(vendor, "__init__.py"), "w") as f:
151+
f.write("\n")
152+
153+
# Copy real Qt.py into myproject
154+
shutil.copy(os.path.join(os.path.dirname(__file__), "Qt.py"),
155+
os.path.join(vendor, "Qt.py"))
156+
157+
print("Testing relative import..")
158+
assert subprocess.call(
159+
["python", "-c", "import myproject"],
160+
cwd=self.tempdir,
161+
stdout=subprocess.PIPE, # With nose process isolation, buffer can
162+
stderr=subprocess.STDOUT, # easily get full and throw an error.
163+
) == 0
164+
165+
print("Testing absolute import..")
166+
assert subprocess.call(
167+
["python", "-c", "from myproject.vendor.Qt import QtWidgets"],
168+
cwd=self.tempdir,
169+
stdout=subprocess.PIPE,
170+
stderr=subprocess.STDOUT,
171+
) == 0
172+
173+
print("Testing direct import..")
174+
assert subprocess.call(
175+
["python", "-c", "import myproject.vendor.Qt"],
176+
cwd=self.tempdir,
177+
stdout=subprocess.PIPE,
178+
stderr=subprocess.STDOUT,
179+
) == 0
173180

174181

175182
if PYTHON == 2:

0 commit comments

Comments
 (0)