Skip to content
This repository was archived by the owner on Dec 31, 2021. It is now read-only.

Commit efb4016

Browse files
committed
ENH: add an easier way to run all tests + enable Travis
Also fix the tox configuration, and add Travis config. Separate the requirements to a separate file that can be reused.
1 parent 2b1dc04 commit efb4016

File tree

8 files changed

+96
-37
lines changed

8 files changed

+96
-37
lines changed

Diff for: .travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# After changing this file, check it on:
2+
# http://lint.travis-ci.org/
3+
language: python
4+
python:
5+
- 2.7
6+
install:
7+
- pip install -r requirements.txt --use-mirrors
8+
script:
9+
- python runtests.py
10+
notifications:
11+
email: false

Diff for: MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
recursive-include scipy_central *.py *.json *.txt *.html
22
include deploy
3+
include requirements.txt
34
recursive-include deploy/templates *.html *.txt
45
recursive-include deploy/media *.html *.css *.png *.jpg *.gif *.less *.js
56
prune deploy/media/code

Diff for: quickstart.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
#!/usr/bin/env python
22
"""
3-
quickstart.py -- set up a virtual environment with necessary dependencies installed
3+
quickstart.py
4+
5+
Set up a virtual environment with necessary dependencies installed
46
57
"""
68
import sys
79
import os
810
import subprocess
911
import argparse
1012

11-
DEPLOY_DIR = os.path.join(os.path.dirname(__file__), 'deploy')
13+
ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
14+
DEPLOY_DIR = os.path.join(ROOT_DIR, 'deploy')
1215
VENV_DIR = os.path.abspath(os.path.join(DEPLOY_DIR, 'env'))
1316

1417
PYVER = "%d.%d" % (sys.version_info[0], sys.version_info[1])
@@ -24,12 +27,6 @@ def find_python():
2427
raise RuntimeError("Something went wrong in virtualenv creation: "
2528
"python and pip not found!")
2629

27-
try:
28-
import virtualenv
29-
except ImportError:
30-
print("ERROR: You need to install Virtualenv (https://pypi.python.org/pypi/virtualenv) first")
31-
sys.exit(0)
32-
3330
def run_cmd(cmd):
3431
print("$ %s" % " ".join(cmd))
3532
ret = subprocess.call(cmd)
@@ -41,6 +38,12 @@ def main():
4138
p = argparse.ArgumentParser(usage=__doc__.strip())
4239
args = p.parse_args()
4340

41+
try:
42+
import virtualenv
43+
except ImportError:
44+
print("ERROR: You need to install Virtualenv (https://pypi.python.org/pypi/virtualenv) first")
45+
sys.exit(0)
46+
4447
try:
4548
find_python()
4649
except RuntimeError:
@@ -50,9 +53,10 @@ def main():
5053

5154
python_bin, easy_install_bin = find_python()
5255

56+
os.chdir(ROOT_DIR)
57+
5358
print("\n-- Installing required modules")
54-
run_cmd([python_bin, 'setup.py', 'egg_info'])
55-
with open(os.path.join('scipy_central.egg-info', 'requires.txt'), 'r') as f:
59+
with open('requirements.txt', 'r') as f:
5660
requirements = [x.strip() for x in f.read().splitlines() if x.strip()]
5761

5862
if sys.platform.startswith('win'):

Diff for: requirements.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Django >=1.4,<1.5
2+
django-haystack <2.0.0
3+
Whoosh
4+
South
5+
django-registration ==0.8
6+
django-widget-tweaks
7+
Sphinx
8+
Pygments
9+
Pillow
10+
Mercurial

Diff for: runtests.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env python
2+
"""
3+
runtests.py
4+
5+
Run all scipy_central tests in the current Python environment.
6+
7+
"""
8+
import sys
9+
import os
10+
import subprocess
11+
import argparse
12+
13+
def main():
14+
p = argparse.ArgumentParser(usage=__doc__.strip())
15+
p.add_argument("--verbose", "-v", action='store_true',
16+
help="show more verbose output")
17+
args = p.parse_args()
18+
19+
# Grab the list of our local apps from Django
20+
21+
base_dir = os.path.abspath(os.path.dirname(__file__))
22+
deploy_dir = os.path.join(base_dir, 'deploy')
23+
app_dir = os.path.join(base_dir, 'scipy_central')
24+
25+
os.chdir(base_dir)
26+
sys.path.insert(0, deploy_dir)
27+
28+
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
29+
mod =__import__('settings')
30+
del os.environ['DJANGO_SETTINGS_MODULE']
31+
32+
apps = [x.replace('scipy_central.', '') for x in mod.INSTALLED_APPS
33+
if x.startswith('scipy_central.')]
34+
35+
if not apps:
36+
print("No apps found to run tests for!")
37+
sys.exit(1)
38+
39+
40+
# Run tests
41+
42+
verbosity = '2' if args.verbose else '1'
43+
44+
cmd = [sys.executable,
45+
os.path.join('deploy', 'manage.py'),
46+
'test', '-v', verbosity, '--noinput', '--traceback'] + apps
47+
48+
sys.exit(subprocess.call(cmd))
49+
50+
if __name__ == "__main__":
51+
main()

Diff for: scipy_central/feeds/models.py

Whitespace-only changes.

Diff for: setup.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,6 @@
55
66
"""
77

8-
REQUIREMENTS = [
9-
'Django >=1.4,<1.5',
10-
'django-haystack <2.0.0',
11-
'Whoosh',
12-
'South',
13-
'django-registration ==0.8',
14-
'django-widget-tweaks',
15-
'Sphinx',
16-
'Pygments',
17-
'Pillow',
18-
'Mercurial',
19-
]
20-
218
METADATA = dict(
229
name='scipy_central',
2310
maintainer = "SciPy Developers",
@@ -67,8 +54,14 @@ def get_version():
6754
version += "-" + git_version()[:6]
6855
return version
6956

57+
def get_requirements():
58+
with open('requirements.txt', 'r') as f:
59+
return [x.strip() for x in f.read().splitlines() if x.strip()]
60+
61+
os.chdir(os.path.abspath(os.path.dirname(__file__)))
62+
7063
setup(version=get_version(),
7164
description = DESCRIPTION.splitlines()[0],
7265
long_description = "".join(DESCRIPTION.splitlines()[2:]),
73-
install_requires=REQUIREMENTS,
66+
install_requires=get_requirements(),
7467
**METADATA)

Diff for: tox.ini

+2-13
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,7 @@
22
envlist = py27
33

44
[testenv]
5-
deps=
6-
Django>=1.4,<1.5
7-
django-haystack
8-
Whoosh
9-
South
10-
django-registration
11-
django-widget-tweaks
12-
Sphinx
13-
Pygments
14-
PIL
15-
Mercurial
16-
5+
deps=-r{toxinidir}/requirements.txt
176
commands=
18-
python deploy/manage.py test -v 2 --traceback filestorage pages person submission tagging screenshot pagehit
7+
python runtests.py
198

0 commit comments

Comments
 (0)