From 12e69da49613e47dfd73b64122613528d5fc667b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=22RooTer=22=20Urba=C5=84ski?= Date: Tue, 12 Jun 2018 13:09:35 +0200 Subject: [PATCH] continuous integration goodies from rooterkyberian (#26) * continuous integration goodies * fixed test_address not running * fixup `python setup.py test` * fixup readme.rst formatting --- .editorconfig | 15 +++++++++++++++ .travis.yml | 19 +++++++++++++++++++ README.rst | 37 +++++++++++++++++++++++++++++++++++++ setup.cfg | 6 ++++++ setup.py | 4 ++++ test_requirements.txt | 6 ++++++ tests/test_address.py | 7 ++++++- tests/utils.py | 14 ++++++++++++++ 8 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 .editorconfig create mode 100644 .travis.yml create mode 100755 setup.cfg create mode 100644 test_requirements.txt create mode 100644 tests/utils.py diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..92efb25 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# http://editorconfig.org + +root = true + +[*] +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true +end_of_line = lf +charset = utf-8 +max_line_length = 120 + +[*.yml] +indent_size = 2 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ae90a9d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +language: python +python: + - "2.7" + - "3.6" + - "nightly" + +matrix: + allow_failures: + python: "nightly" + +cache: pip +before_install: + - pip install -r test_requirements.txt +install: + - pip install -e . # install dependencies as specified in setup.py +script: + - pytest +after_success: + - coveralls diff --git a/README.rst b/README.rst index 5f27b0a..bc00e9b 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,17 @@ Python Monero module ==================== +|travis|_ |coveralls|_ + + +.. |travis| image:: https://travis-ci.org/emesik/monero-python.svg +.. _travis: https://travis-ci.org/emesik/monero-python + + +.. |coveralls| image:: https://coveralls.io/repos/github/emesik/monero-python/badge.svg +.. _coveralls: https://coveralls.io/github/emesik/monero-python + + A comprehensive Python module for handling Monero cryptocurrency. * release 0.3 @@ -40,3 +51,29 @@ Want to help? If you find this project useful, please consider a donation to the following address: ``481SgRxo8hwBCY4z6r88JrN5X8JFCJYuJUDuJXGybTwaVKyoJPKoGj3hQRAEGgQTdmV1xH1URdnHkJv6He5WkEbq6iKhr94`` + + +Development +----------- + +1. Clone the repo +2. Create virtualenv & activate it + +.. code-block:: bash + + python3.6 -m venv .venv + source .venv/bin/activate + +3. Install dependencies + +.. code-block:: bash + + pip install -r requirements.txt -r test_requirements.txt + +4. Do your thing + +5. Run tests + +.. code-block:: bash + + pytest diff --git a/setup.cfg b/setup.cfg new file mode 100755 index 0000000..4e09314 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,6 @@ +[aliases] +test=pytest + +[tool:pytest] +rootdir=tests +addopts=--cov=monero diff --git a/setup.py b/setup.py index af93d1c..4114151 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,10 @@ setup( url = 'https://github.com/emesik/monero-python/', long_description = open('README.rst', 'rb').read().decode('utf-8'), install_requires = open('requirements.txt', 'r').read().splitlines(), + tests_requires=open('test_requirements.txt', 'r').read().splitlines(), + setup_requires=[ + 'pytest-runner', + ], packages = find_packages('.', exclude=['tests']), include_package_data = True, author = 'Michał Sałaban', diff --git a/test_requirements.txt b/test_requirements.txt new file mode 100644 index 0000000..1d000ae --- /dev/null +++ b/test_requirements.txt @@ -0,0 +1,6 @@ +coverage~=4.5.1 +coveralls +pip>=9 +pytest-cov~=2.5 +pytest-runner~=4.2 +pytest~=3.6 diff --git a/tests/test_address.py b/tests/test_address.py index 68ef51c..73e8efd 100644 --- a/tests/test_address.py +++ b/tests/test_address.py @@ -1,8 +1,14 @@ import unittest from monero.address import Address, SubAddress, IntegratedAddress, address +from tests.utils import classproperty + class Tests(object): + @classproperty + def __test__(cls): + return issubclass(cls, unittest.TestCase) + def test_from_and_to_string(self): a = Address(self.addr) self.assertEqual(str(a), self.addr) @@ -112,7 +118,6 @@ class Tests(object): address, 'Cf6RinMUztY5otm6NEFjg3UWBBkXK6Lh23wKrLFMEcCY7i3A6aPLH9i4QMCkf6CdWk8Q9N7yoJf7ANKgtQMuPM6JANXgCWs') - def test_type_mismatch(self): self.assertRaises(ValueError, Address, self.iaddr) self.assertRaises(ValueError, Address, self.subaddr) diff --git a/tests/utils.py b/tests/utils.py new file mode 100644 index 0000000..fbdbc8e --- /dev/null +++ b/tests/utils.py @@ -0,0 +1,14 @@ +class ClassPropertyDescriptor(object): + """Based on https://stackoverflow.com/questions/5189699/how-to-make-a-class-property""" + + def __init__(self, fget): + self.fget = fget + + def __get__(self, obj, klass): + if klass is None: + klass = type(obj) + return self.fget.__get__(obj, klass)() + + +def classproperty(func): + return ClassPropertyDescriptor(classmethod(func))