Skip to content

Commit

Permalink
Merge pull request #104 from medecau/update-tests
Browse files Browse the repository at this point in the history
Update tests
  • Loading branch information
john-kurkowski authored Aug 30, 2016
2 parents 5337a2e + 7118ea6 commit fa2b093
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 48 deletions.
27 changes: 13 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
sudo: false
language: python
env:
- REQUESTS_VERSION=2.1.0
- REQUESTS_VERSION=2.8.1
- REQUESTS_VERSION=2.9.1
python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
- "3.5"
install:
- if [[ $TRAVIS_PYTHON_VERSION == 2.6* ]]; then export PYTEST_ADDOPTS='-p no:pylint'; fi
- pip install -r requirements.txt
- pip install --upgrade --force-reinstall requests==$REQUESTS_VERSION
script: py.test
- TOXENV=py27-requests-current
- TOXENV=py33-requests-current
- TOXENV=py34-requests-current
- TOXENV=py35-requests-current
- TOXENV=py35-requests-2.1.0
- TOXENV=py35-requests-2.8.1
- TOXENV=py35-requests-2.9.1
- TOXENV=pypy-requests-current
- TOXENV=codestyle
python: 3.5
install: pip install tox
script: tox
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,24 +199,25 @@ curl "http://tldextract.appspot.com/api/extract?url=http://www.bbc.co.uk/foo/bar

## Contribute

### Installation

You probably want to set up a [virtualenv](http://virtualenv.readthedocs.org/en/latest/index.html).
### Setting up

1. `git clone` this repository.
2. Change into the new directory.
3. `pip install -r requirements.txt`
3. `pip install tox`

Alternatively you can install `detox` instead of `tox` to run tests in parallel.

### Running the Test Suite

Run all tests against your current Python version:
Run all tests against all supported Python versions:

```zsh
py.test
tox
```

Or against all supported Python versions:
Run all tests against a specific Python environment configuration:

```zsh
tox
tox -l
tox -e py35-requests-2.9.1
```
10 changes: 0 additions & 10 deletions requirements.txt

This file was deleted.

6 changes: 3 additions & 3 deletions tests/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def test_result_as_dict():
"http://admin:[email protected]:666"
"/secret/admin/interface?param1=42"
)
expected_dict = {'subdomain' : 'www',
'domain' : 'google',
'suffix' : 'com'}
expected_dict = {'subdomain': 'www',
'domain': 'google',
'suffix': 'com'}
assert result._asdict() == expected_dict
2 changes: 1 addition & 1 deletion tldextract/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
from .tldextract import extract, TLDExtract

try:
__version__ = pkg_resources.get_distribution('tldextract').version # pylint: disable=no-member
__version__ = pkg_resources.get_distribution('tldextract').version # pylint: disable=no-member
except pkg_resources.DistributionNotFound as _:
__version__ = '(local)'
8 changes: 4 additions & 4 deletions tldextract/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
try:
unicode
except NameError:
unicode = str # pylint: disable=invalid-name,redefined-builtin
unicode = str # pylint: disable=invalid-name,redefined-builtin


def main():
Expand All @@ -19,15 +19,15 @@ def main():
logging.basicConfig()

try:
__version__ = pkg_resources.get_distribution('tldextract').version # pylint: disable=no-member
__version__ = pkg_resources.get_distribution('tldextract').version # pylint: disable=no-member
except pkg_resources.DistributionNotFound as _:
__version__ = '(local)'

parser = argparse.ArgumentParser(
prog='tldextract',
description='Parse hostname from a url or fqdn')

parser.add_argument('--version', action='version', version='%(prog)s ' + __version__) # pylint: disable=no-member
parser.add_argument('--version', action='version', version='%(prog)s ' + __version__) # pylint: disable=no-member
parser.add_argument('input', metavar='fqdn|url',
type=unicode, nargs='*', help='fqdn or url')

Expand All @@ -51,4 +51,4 @@ def main():
exit(1)

for i in args.input:
print(' '.join(tld_extract(i))) # pylint: disable=superfluous-parens
print(' '.join(tld_extract(i))) # pylint: disable=superfluous-parens
2 changes: 1 addition & 1 deletion tldextract/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# pylint: enable=import-error,invalid-name,no-name-in-module,redefined-builtin


IP_RE = re.compile(r'^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$') # pylint: disable=line-too-long
IP_RE = re.compile(r'^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$') # pylint: disable=line-too-long
SCHEME_RE = re.compile(r'^([' + scheme_chars + ']+:)?//')

LOG = logging.getLogger('tldextract')
Expand Down
6 changes: 3 additions & 3 deletions tldextract/tldextract.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
try:
import pkg_resources
except ImportError:
class pkg_resources(object): # pylint: disable=invalid-name
class pkg_resources(object): # pylint: disable=invalid-name

"""Fake pkg_resources interface which falls back to getting resources
inside `tldextract`'s directory.
Expand Down Expand Up @@ -126,7 +126,7 @@ class TLDExtract(object):
a URL.'''

# TODO: Agreed with Pylint: too-many-arguments
def __init__(self, cache_file=CACHE_FILE, suffix_list_urls=PUBLIC_SUFFIX_LIST_URLS, # pylint: disable=too-many-arguments
def __init__(self, cache_file=CACHE_FILE, suffix_list_urls=PUBLIC_SUFFIX_LIST_URLS, # pylint: disable=too-many-arguments
fallback_to_snapshot=True, include_psl_private_domains=False, extra_suffixes=()):
"""
Constructs a callable for extracting subdomain, domain, and suffix
Expand Down Expand Up @@ -318,7 +318,7 @@ def _cache_tlds(self, tlds):
with open(self.cache_file, 'w') as cache_file:
json.dump(tlds, cache_file)
except IOError as ioe:
LOG.warn("unable to cache TLDs in file %s: %s", self.cache_file, ioe)
LOG.warning("unable to cache TLDs in file %s: %s", self.cache_file, ioe)


TLD_EXTRACTOR = TLDExtract()
Expand Down
4 changes: 2 additions & 2 deletions tldextract_app/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class Extract(object):

def GET(self): # pylint: disable=invalid-name,no-self-use
def GET(self): # pylint: disable=invalid-name,no-self-use
url = web.input(url='').url
if not url:
return web.webapi.badrequest()
Expand All @@ -27,7 +27,7 @@ def GET(self): # pylint: disable=invalid-name,no-self-use

class TLDSet(object):

def GET(self): # pylint: disable=invalid-name,no-self-use
def GET(self): # pylint: disable=invalid-name,no-self-use
web.header('Content-Type', 'text/html; charset=utf-8')
return '<br/>'.join(sorted(tldextract.tldextract.TLD_EXTRACTOR.tlds))

Expand Down
20 changes: 18 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
[tox]
envlist = py26, py27, py33, py34, py35, pypy
envlist = py{27,33,34,35,py}-requests-{current,2.1.0,2.8.1,2.9.1},codestyle

[testenv]
deps =
pylint
pytest
pytest-gitignore
pytest-mock
pytest-pylint

py{27,33,34,35,py}-requests-current: requests
py{27,33,34,35,py}-requests-2.1.0: requests==2.1.0
py{27,33,34,35,py}-requests-2.8.1: requests==2.8.1
py{27,33,34,35,py}-requests-2.9.1: requests==2.9.1

commands = py.test
deps = -rrequirements.txt

[testenv:codestyle]
deps = pycodestyle
# E501 - line too long
commands = pycodestyle tldextract tldextract_app tests --ignore=E501

0 comments on commit fa2b093

Please sign in to comment.