Skip to content

Commit 2ccd8eb

Browse files
authored
tests run improvements: update from python setup.py test -> tox (#754)
* tests cleanup: - move test requirements to test_requirements.txt to share between setup.py and tox.ini - README: update to recommend using 'tox --current-env' for running tests locally - replaces #741 * test tweaks: - don't require i18n to import locmanager, instead set flag on load (to avoid breaking tox / pytest) - don't add werkzeug to test requirements
1 parent f0340c6 commit 2ccd8eb

File tree

7 files changed

+43
-40
lines changed

7 files changed

+43
-40
lines changed

README.rst

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,36 @@ The 2.x release included a major overhaul of pywb and introduces many new featur
5555
Please see the `full documentation <https://pywb.readthedocs.org>`_ for more detailed info on all these features.
5656

5757

58-
Installation
59-
------------
58+
Installation for Deployment
59+
---------------------------
60+
61+
To install pywb for usage, you can use:
6062

6163
```shell
6264
pip install pywb
6365
```
6466

6567
Note: depending on your Python installation, you may have to use `pip3` instead of `pip`.
6668

67-
To install, test and build docs locally you can:
6869

69-
* Install with ``python setup.py install``
70+
Installation from local copy
71+
----------------------------
72+
73+
```shell
74+
git clone https://github.com/webrecorder/pywb
75+
```
76+
77+
To install from a locally cloned copy, install with ``pip install -e .`` or ``python setup.py install``.
78+
79+
To run tests, we recommend installing ``pip install tox tox-current-env`` and then running ``tox --current-env`` to test in your current Python environment.
7080

71-
* Run tests with ``python setup.py test``
81+
To Build docs locally, run: ``cd docs; make html``. (The docs will be built in ``./_build/html/index.html``)
7282

73-
* Run Wayback with ``wayback`` (see docs for info on how to setup collections)
7483

75-
* Build docs locally with: ``cd docs; make html``. (The docs will be built in ``./_build/html/index.html``)
84+
Running
85+
-------
7686

87+
After installation, you can run ``pywb`` or ``wayback``.
7788

7889
Consult the local or `online docs <https://pywb.readthedocs.org>`_ for latest usage and configuration details.
7990

pywb/manager/locmanager.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
import os.path
33
import shutil
44

5-
from babel.messages.frontend import CommandLineInterface
6-
7-
from translate.convert.po2csv import main as po2csv
8-
from translate.convert.csv2po import main as csv2po
5+
try:
6+
from babel.messages.frontend import CommandLineInterface
7+
8+
from translate.convert.po2csv import main as po2csv
9+
from translate.convert.csv2po import main as csv2po
10+
loc_avail = True
11+
except:
12+
loc_avail = False
913

1014

1115
ROOT_DIR = 'i18n'

pywb/manager/manager.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,12 +448,7 @@ def do_acl(r):
448448
acl.set_defaults(func=do_acl)
449449

450450
# LOC
451-
loc_avail = False
452-
try:
453-
from pywb.manager.locmanager import LocManager
454-
loc_avail = True
455-
except:
456-
pass
451+
from pywb.manager.locmanager import LocManager, loc_avail
457452

458453
def do_loc(r):
459454
if not loc_avail:

setup.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,7 @@ def get_package_data():
113113
"translate_toolkit"
114114
],
115115
},
116-
tests_require=[
117-
'pytest',
118-
'WebTest',
119-
'pytest-cov',
120-
'mock',
121-
'urllib3',
122-
'werkzeug',
123-
'httpbin==0.5.0',
124-
'ujson',
125-
'lxml'
126-
],
116+
tests_require=load_requirements("test_requirements.txt"),
127117
cmdclass={'test': PyTest},
128118
test_suite='',
129119
entry_points="""

test_requirements.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pytest
2+
WebTest
3+
pytest-cov
4+
mock
5+
urllib3
6+
httpbin==0.5.0
7+
flask<2.0
8+
ujson
9+
lxml

tests/test_locales.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
from .base_config_test import BaseConfigTest
2+
import pytest
23

34

45
# ============================================================================
56
class TestLocales(BaseConfigTest):
67
@classmethod
78
def setup_class(cls):
89
super(TestLocales, cls).setup_class('config_test_loc.yaml')
10+
pytest.importorskip('babel')
11+
pytest.importorskip('translate_toolkit')
912

1013
def test_locale_en_home(self):
1114
res = self.testapp.get('/en/')

tox.ini

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,19 @@ testpaths =
44
tests
55

66
[tox]
7-
envlist = py36, py37, py38, py39
7+
envlist = py36, py37, py38, py39, py310
88

99
[gh-actions]
1010
python =
1111
3.6: py36
1212
3.7: py37
1313
3.8: py38
1414
3.9: py39
15+
3.10: py39
1516

1617
[testenv]
1718
deps =
18-
pytest
19-
pytest-cov
20-
coverage
21-
WebTest
22-
fakeredis<1.0
23-
mock
24-
urllib3
25-
werkzeug
26-
httpbin==0.5.0
27-
ujson
28-
lxml
19+
-rtest_requirements.txt
2920
-rrequirements.txt
3021
-rextra_requirements.txt
3122
commands =

0 commit comments

Comments
 (0)