Skip to content

Commit

Permalink
Merge branch 'master' into feature/python312Support
Browse files Browse the repository at this point in the history
  • Loading branch information
wumpus authored Aug 21, 2024
2 parents e79cce0 + 12eca85 commit e0b444e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 19 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ jobs:
- name: Install warcio
run: python setup.py install

- name: Install test dependencies
run: pip install -e ".[testing]"

- name: Run tests
run: python setup.py test
run: python -m pytest

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
5 changes: 5 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[pytest]
addopts = -v --cov warcio --doctest-modules
testpaths =
warcio
test
27 changes: 11 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ def finalize_options(self):
# should work with setuptools <18, 18 18.5
self.test_suite = ' '

def run_tests(self):
import pytest
import sys
import os
errcode = pytest.main(['--doctest-modules', './warcio', '--cov', 'warcio', '-v', 'test/'])
sys.exit(errcode)

setup(
name='warcio',
version=__version__,
Expand All @@ -44,15 +37,17 @@ def run_tests(self):
""",
cmdclass={'test': PyTest},
test_suite='',
tests_require=[
'urllib3>=1.26.4,<1.26.16',
'pytest',
'pytest-cov',
'httpbin>=0.10.2',
'requests',
'wsgiprox',
'hookdns',
],
extras_require={
'testing': [
'urllib3==1.25.11',
'pytest',
'pytest-cov',
'httpbin>=0.10.2',
'requests',
'wsgiprox',
'hookdns',
]
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
Expand Down
6 changes: 6 additions & 0 deletions test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
import tempfile
import os

def test_version(capsys):
with pytest.raises(SystemExit):
main(args=['--version'])
out, err = capsys.readouterr()
print(out, err)
assert len(out) > 0

def test_index(capsys):
files = ['example.warc.gz', 'example.warc', 'example.arc.gz', 'example.arc']
Expand Down
10 changes: 8 additions & 2 deletions warcio/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
from warcio.extractor import Extractor
from warcio.recompressor import Recompressor


try:
from importlib.metadata import version
except ImportError:
import pkg_resources
def version(package):
return pkg_resources.get_distribution(package).version
import sys


Expand Down Expand Up @@ -57,8 +64,7 @@ def main(args=None):

# ============================================================================
def get_version():
import pkg_resources
return '%(prog)s ' + pkg_resources.get_distribution('warcio').version
return '%(prog)s ' + version('warcio')


# ============================================================================
Expand Down

0 comments on commit e0b444e

Please sign in to comment.