From f52b08ddbb1d855261317129c9b2b3ec92c13613 Mon Sep 17 00:00:00 2001 From: Alex Damian Date: Thu, 15 Sep 2016 15:43:59 +0100 Subject: [PATCH 1/7] Add tests We add basic unit tests. --- tests.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests.py diff --git a/tests.py b/tests.py new file mode 100644 index 0000000..124008e --- /dev/null +++ b/tests.py @@ -0,0 +1,23 @@ +# Copyright YPlan 2016 +# Under MIT license + +# Use PyTest to run this +# pytest ./tests.py + +import gibberish + + +def test_generate_word(): + word = gibberish.generate_word() + assert len(word) + assert word.isalpha() + + +def test_generate_words(): + word_list = gibberish.generate_word() + + assert len(word_list) + + for word in word_list: + assert len(word) + assert word.isalpha() From b949e624bfed79e34b2a34932538f532f1f095f7 Mon Sep 17 00:00:00 2001 From: Adam Chainz Date: Thu, 15 Sep 2016 16:22:29 +0100 Subject: [PATCH 2/7] setup.py - a few updates * only use setuptools since it's 2016 * don't leave README file pointer open --- setup.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/setup.py b/setup.py index e821b48..1713cb8 100644 --- a/setup.py +++ b/setup.py @@ -1,20 +1,12 @@ import os -try: - # use setuptools if available - from setuptools import setup - kwargs = { - 'entry_points': {'console_scripts': - 'gibberish = gibberish:console_main', - } - } -except ImportError: - # fall back to distutils - from distutils import setup - kwargs = {} +from setuptools import setup base_dir = os.path.dirname(os.path.abspath(__file__)) +with open(os.path.join(base_dir, 'README.rst')) as fp: + long_description = fp.read() + setup( name='Gibberish', description="A pseudo-word generator", @@ -24,6 +16,8 @@ url='https://github.com/greghaskins/gibberish', py_modules=('gibberish',), license='MIT License', - long_description=open(os.path.join(base_dir, 'README.rst')).read(), - **kwargs + long_description=long_description, + entry_points={ + 'console_scripts': 'gibberish = gibberish:console_main', + } ) From 78c4a5ed8b00a805d664f857cdf3bd1b7cb4d119 Mon Sep 17 00:00:00 2001 From: ddalex Date: Thu, 15 Sep 2016 16:55:11 +0100 Subject: [PATCH 3/7] Prepare to submit (#3) * Prepare to submit Updating setup.py to prepare for PyPi submit. We don't want to take credit from the original author, so we're adding ourselves as maintainers. use proper module name use YPlan identification --- LICENSE.txt | 1 + setup.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index c06d528..58e9c2d 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,5 @@ Copyright (c) 2011-2012 Gregory Haskins, http://greghaskins.com +Copyright (c) 2016 YPlan, http://github.com/YPlan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/setup.py b/setup.py index 1713cb8..699d705 100644 --- a/setup.py +++ b/setup.py @@ -8,15 +8,24 @@ long_description = fp.read() setup( - name='Gibberish', + name='gibberish', description="A pseudo-word generator", - version='0.2', + version='0.3', author='Gregory Haskins', author_email='greg@greghaskins.com', - url='https://github.com/greghaskins/gibberish', + maintainer='YPlan', + maintainer_email='alex.damian@yplanapp.com', + url='https://github.com/YPlan/gibberish', py_modules=('gibberish',), license='MIT License', long_description=long_description, + classifiers=[ + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Natural Language :: English', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3', + ], entry_points={ 'console_scripts': 'gibberish = gibberish:console_main', } From 78e7ce407a05d61f6c3453b043b0d1b50c1e35e2 Mon Sep 17 00:00:00 2001 From: Alex Damian Date: Thu, 15 Sep 2016 17:05:17 +0100 Subject: [PATCH 4/7] Use correct README file, fix travis.yml Python's setup.py looks for README, not README.rst file. So we use that. Additionally, we add the build instructions for travis. --- .travis.yml | 9 +++++++++ setup.py | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c410e82 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: python +python: + - "2.7" + - "3.5" + - "3.6" +before_install: + - pip install pytest +script: + - pytest ./tests.py diff --git a/setup.py b/setup.py index 699d705..63a0593 100644 --- a/setup.py +++ b/setup.py @@ -4,13 +4,13 @@ base_dir = os.path.dirname(os.path.abspath(__file__)) -with open(os.path.join(base_dir, 'README.rst')) as fp: +with open(os.path.join(base_dir, 'README')) as fp: long_description = fp.read() setup( name='gibberish', description="A pseudo-word generator", - version='0.3', + version='0.3.1', author='Gregory Haskins', author_email='greg@greghaskins.com', maintainer='YPlan', From 6574a33f8c93d2c649164b152bbe7f20d3e93f90 Mon Sep 17 00:00:00 2001 From: ddalex Date: Thu, 15 Sep 2016 17:14:35 +0100 Subject: [PATCH 5/7] Fix travis CI (#4) - drop Py 3.6 requirement - explicitly install pytest --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c410e82..f09f571 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,6 @@ language: python python: - "2.7" - "3.5" - - "3.6" -before_install: - - pip install pytest +install: "pip install pytest==3.0.0" script: - pytest ./tests.py From c5e40e082de0c6b24593a549120ea41633034ab6 Mon Sep 17 00:00:00 2001 From: Adam Chainz Date: Thu, 22 Sep 2016 10:48:02 +0100 Subject: [PATCH 6/7] Tidy packaging * Include README.rst and LICENSE.txt in output package * Remove unnecessary README -> README.rst symlink * Support universal wheels --- MANIFEST.in | 2 ++ README | 1 - setup.cfg | 2 ++ setup.py | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 MANIFEST.in delete mode 120000 README create mode 100644 setup.cfg diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..97e2ad3 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include LICENSE.txt +include README.rst diff --git a/README b/README deleted file mode 120000 index 92cacd2..0000000 --- a/README +++ /dev/null @@ -1 +0,0 @@ -README.rst \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..2a9acf1 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal = 1 diff --git a/setup.py b/setup.py index 63a0593..52748d3 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ base_dir = os.path.dirname(os.path.abspath(__file__)) -with open(os.path.join(base_dir, 'README')) as fp: +with open(os.path.join(base_dir, 'README.rst')) as fp: long_description = fp.read() setup( From da4c5e70ffe7f4e7931c7e6b20609236e5208643 Mon Sep 17 00:00:00 2001 From: Adam Chainz Date: Thu, 22 Sep 2016 12:03:00 +0100 Subject: [PATCH 7/7] Improve testing * Use `tox` so that the test process can be run easily locally, the same as is run on Travis * Make travis run `tox`, and use containers so it's faster * Lock requirements with `pip-compile`, and only install the locked requirements in `tox.ini` * Rename the test file so it gets discovered by `pytest` * Remove unnecessary header in test file since the test process is now standard --- .travis.yml | 15 +++++++++------ requirements.in | 1 + requirements.txt | 8 ++++++++ tests.py => test_it.py | 6 ------ tox.ini | 7 +++++++ 5 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 requirements.in create mode 100644 requirements.txt rename tests.py => test_it.py (77%) create mode 100644 tox.ini diff --git a/.travis.yml b/.travis.yml index f09f571..210d02e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,10 @@ +# Config file for automatic testing at travis-ci.org +sudo: false + language: python -python: - - "2.7" - - "3.5" -install: "pip install pytest==3.0.0" -script: - - pytest ./tests.py +python: 3.5 + +install: + - pip install tox + +script: tox diff --git a/requirements.in b/requirements.in new file mode 100644 index 0000000..e079f8a --- /dev/null +++ b/requirements.in @@ -0,0 +1 @@ +pytest diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9716eb7 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile --output-file requirements.txt requirements.in +# +py==1.4.31 # via pytest +pytest==3.0.2 diff --git a/tests.py b/test_it.py similarity index 77% rename from tests.py rename to test_it.py index 124008e..7465447 100644 --- a/tests.py +++ b/test_it.py @@ -1,9 +1,3 @@ -# Copyright YPlan 2016 -# Under MIT license - -# Use PyTest to run this -# pytest ./tests.py - import gibberish diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..2474577 --- /dev/null +++ b/tox.ini @@ -0,0 +1,7 @@ +[tox] +envlist = py{27,35} + +[testenv] +install_command = pip install --no-deps {opts} {packages} +deps = -rrequirements.txt +commands = py.test {posargs}