Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 61 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,62 @@
*.pyc
dist
build
*.egg-info
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Project specific
*.mmdb
docs/_build
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: python
python: 3.5
env:
- TOX_ENV=py26
- TOX_ENV=py27
- TOX_ENV=py33
- TOX_ENV=py34
- TOX_ENV=py35
- TOX_ENV=lint
- TOX_ENV=docs
install: pip install tox
script: tox -e $TOX_ENV
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ using the GeoIP database right away::
'NA'
>>> match.timezone
'America/Los_Angeles'
>>> match.subdivisions
frozenset(['CA'])
>>> list(match.subdivisions)
['CA']

If you want to use your own MaxMind database (for instance because you
paid for the commercial version) you can open the database yourself::

>>> from geoip import open_database
>>> db = open_database('path/to/my.mmdb')
>>> db = open_database('path/to/my.mmdb') # doctest: +SKIP

API
---
Expand Down
1 change: 1 addition & 0 deletions geoip.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ def _read_mmdb_metadata(buf):

def make_struct_parser(code):
struct = Struct('>' + code)

def unpack_func(self, size, offset):
new_offset = offset + struct.size
bytes_read = self._buf[offset:new_offset].rjust(struct.size, b'\x00')
Expand Down
1 change: 1 addition & 0 deletions geolite2/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
)
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'License :: OSI Approved :: BSD License',
],
)
25 changes: 25 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[tox]
envlist = py{26,27,33,34,35}, lint

[testenv]
commands = py.test {posargs}
deps =
python-geoip-geolite2-yplan==2015.1103.1
pygments==2.0.2
pytest==2.8.3

[testenv:lint]
deps =
flake8==2.4.0
commands=flake8 geoip.py geolite2 tests

[testenv:docs]
changedir=docs
deps=
sphinx
commands=
sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html

[pytest]
addopts = --doctest-modules --doctest-glob='*.rst' --ignore=setup.py --ignore=docs/conf.py --ignore geolite2/setup.py
doctest_optionflags = NORMALIZE_WHITESPACE