From 4e16ed75bd0fb1877bb0980ff18fa9d2bfe71757 Mon Sep 17 00:00:00 2001 From: Maciej Urbanski Date: Wed, 6 Jun 2018 11:45:14 +0200 Subject: [PATCH 1/4] continuous integration goodies --- .editorconfig | 15 +++++++++++++++ .travis.yml | 19 +++++++++++++++++++ README.rst | 11 +++++++++++ setup.cfg | 6 ++++++ test_requirements.txt | 5 +++++ tests/test_address.py | 3 +++ 6 files changed, 59 insertions(+) create mode 100644 .editorconfig create mode 100644 .travis.yml create mode 100755 setup.cfg create mode 100644 test_requirements.txt 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 f703172..d156f18 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 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/test_requirements.txt b/test_requirements.txt new file mode 100644 index 0000000..c42d737 --- /dev/null +++ b/test_requirements.txt @@ -0,0 +1,5 @@ +coverage~=4.5.1 +pytest~=3.6 +pytest-cov~=2.5 +pip>=9 +coveralls diff --git a/tests/test_address.py b/tests/test_address.py index cd91ad3..b6fa045 100644 --- a/tests/test_address.py +++ b/tests/test_address.py @@ -2,7 +2,10 @@ from monero.address import Address, SubAddress, IntegratedAddress, address + class Tests(object): + __test__ = False + def test_from_and_to_string(self): a = Address(self.addr) self.assertEqual(str(a), self.addr) From 540609e20b0919b765f7d4e313b64dacc2260ec7 Mon Sep 17 00:00:00 2001 From: Maciej Urbanski Date: Wed, 6 Jun 2018 16:22:46 +0200 Subject: [PATCH 2/4] fixed test_address not running --- README.rst | 18 ++++++++++++++++++ tests/test_address.py | 6 ++++-- tests/utils.py | 14 ++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 tests/utils.py diff --git a/README.rst b/README.rst index d156f18..cc134e1 100644 --- a/README.rst +++ b/README.rst @@ -50,3 +50,21 @@ 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, `python3.6 -m venv .venv` +3. Install dependencies + +.. code-block:: python + pip install -r requirements.txt -r test_requirements.txt` + +4. Do your thing + +5. Run tests + +.. code-block:: python + pytest diff --git a/tests/test_address.py b/tests/test_address.py index b6fa045..c6eca28 100644 --- a/tests/test_address.py +++ b/tests/test_address.py @@ -1,10 +1,13 @@ import unittest from monero.address import Address, SubAddress, IntegratedAddress, address +from tests.utils import classproperty class Tests(object): - __test__ = False + @classproperty + def __test__(cls): + return issubclass(cls, unittest.TestCase) def test_from_and_to_string(self): a = Address(self.addr) @@ -115,7 +118,6 @@ def test_invalid(self): 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)) From c3513aac350e55f15b64078e7ad28b0c234166cc Mon Sep 17 00:00:00 2001 From: Maciej Urbanski Date: Wed, 6 Jun 2018 16:46:34 +0200 Subject: [PATCH 3/4] fixup `python setup.py test` --- setup.py | 4 ++++ test_requirements.txt | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 0b6ea59..a6cec26 100644 --- a/setup.py +++ b/setup.py @@ -11,6 +11,10 @@ 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 index c42d737..1d000ae 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -1,5 +1,6 @@ coverage~=4.5.1 -pytest~=3.6 -pytest-cov~=2.5 -pip>=9 coveralls +pip>=9 +pytest-cov~=2.5 +pytest-runner~=4.2 +pytest~=3.6 From 6dcc1af8232fe4776bd7fcf4debec315008d3577 Mon Sep 17 00:00:00 2001 From: Maciej Urbanski Date: Thu, 7 Jun 2018 23:48:42 +0200 Subject: [PATCH 4/4] fixup readme.rst formatting --- README.rst | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index cc134e1..9e014a5 100644 --- a/README.rst +++ b/README.rst @@ -56,15 +56,23 @@ Development ----------- 1. Clone the repo -2. Create virtualenv & activate it, `python3.6 -m venv .venv` +2. Create virtualenv & activate it + +.. code-block:: bash + + python3.6 -m venv .venv + source .venv/bin/activate + 3. Install dependencies -.. code-block:: python - pip install -r requirements.txt -r test_requirements.txt` +.. code-block:: bash + + pip install -r requirements.txt -r test_requirements.txt 4. Do your thing 5. Run tests -.. code-block:: python +.. code-block:: bash + pytest