From 815bc4618a4f5cb46a737df8d39d2dcc1511387c Mon Sep 17 00:00:00 2001
From: Chenxiong Qi <cqi@redhat.com>
Date: Apr 01 2018 07:14:10 +0000
Subject: [PATCH 1/3] Use tox to run tests with multiple Python versions


Signed-off-by: Chenxiong Qi <cqi@redhat.com>

---

diff --git a/.gitignore b/.gitignore
index 719a3b7..36d84a0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,5 @@ dist/
 .coverage
 .cache
 .eggs
+.env/
+.tox/
diff --git a/MANIFEST.in b/MANIFEST.in
index 2cc81b6..cfe82df 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -4,3 +4,5 @@ include doc/release-guide.markdown
 include test/utils.py
 include test *.conf
 recursive-include conf *
+include tox.ini
+include requirements.txt tests-requirements.txt
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..c8dd6bc
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,4 @@
+openidc-client
+python-bugzilla
+rpkg
+six
diff --git a/setup.py b/setup.py
index 59cc9fc..eab0256 100755
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,8 @@
 #!/usr/bin/python
+
+import os
+import sys
+
 from setuptools import setup, find_packages
 
 try:
@@ -13,6 +17,23 @@ def bash_completion_dir():
     return output if not sts and output else '/etc/bash_completion.d'
 
 
+project_dir = os.path.dirname(os.path.realpath(__file__))
+requirements = os.path.join(project_dir, 'requirements.txt')
+tests_requirements = os.path.join(project_dir, 'tests-requirements.txt')
+
+with open(requirements, 'r') as f:
+    install_requires = [line.strip() for line in f]
+
+with open(tests_requirements, 'r') as f:
+    tests_require = [line.strip() for line in f]
+
+ver = sys.version_info
+if ver[0] <= 2 and ver[1] < 7:
+    tests_require += [
+        'unittest2'
+    ]
+
+
 setup(
     name="fedpkg",
     version="1.32",
@@ -29,7 +50,8 @@ setup(
                 ('/usr/share/zsh/site-functions', ['conf/zsh-completion/_fedpkg']),
                 ],
 
-    tests_require=['nose', 'mock'],
+    install_requires=install_requires,
+    tests_require=tests_require,
     test_suite='nose.collector',
 
     entry_points={
@@ -37,5 +59,19 @@ setup(
             'fedpkg = fedpkg.__main__:main',
             'fedpkg-stage = fedpkg.__main__:main',
         ],
-    }
+    },
+
+    classifiers=[
+        'Development Status :: 5 - Production/Stable',
+        'Environment :: Console',
+        'Intended Audience :: Developers',
+        'Topic :: Software Development :: Build Tools',
+        'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
+        'Programming Language :: Python :: 2',
+        'Programming Language :: Python :: 2.6',
+        'Programming Language :: Python :: 2.7',
+        'Programming Language :: Python :: 3',
+        'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
+    ],
 )
diff --git a/tests-requirements.txt b/tests-requirements.txt
new file mode 100644
index 0000000..cdfe964
--- /dev/null
+++ b/tests-requirements.txt
@@ -0,0 +1,3 @@
+mock == 1.0.1
+nose == 1.3.7
+nose-cov
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..942339f
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,20 @@
+[tox]
+envlist = py26,py27,py36,flake8
+
+[testenv]
+deps =
+    -r{toxinidir}/requirements.txt
+    -r{toxinidir}/tests-requirements.txt
+commands =
+    pip install -I --install-option="--with-openssl" "pycurl>=7.19"
+    nosetests {posargs}
+
+[testenv:py26]
+commands =
+    pip install -I "setuptools<37.0.0" "wheel<0.30.0" unittest2
+    {[testenv]commands}
+
+[testenv:flake8]
+skip_install = True
+deps = flake8 == 3.5.0
+commands = flake8 fedpkg/ test/
\ No newline at end of file

From c577ce7f1849102e8216b335408f2e3001d58031 Mon Sep 17 00:00:00 2001
From: Chenxiong Qi <cqi@redhat.com>
Date: Apr 01 2018 07:14:10 +0000
Subject: [PATCH 2/3] Fix fake PDC URL in test


Signed-off-by: Chenxiong Qi <cqi@redhat.com>

---

diff --git a/test/test_utils.py b/test/test_utils.py
index 7ca395f..60cbf6c 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -109,7 +109,7 @@ class TestUtils(CliTestCase):
         for eol in ['2030-01-01', '2030-12-25']:
             try:
                 sls = {'security_fixes': eol, 'bug_fixes': '2030-12-01'}
-                utils.verify_sls('abc', sls)
+                utils.verify_sls('http://pdc.example.com/', sls)
                 assert False, 'An rpkgError exception was not raised'
             except rpkgError as e:
                 assert str(e) == ('The SL "{0}" must expire on June 1st or '

From c40b71f7636b2ffd0e094c16289507b167112c8a Mon Sep 17 00:00:00 2001
From: Chenxiong Qi <cqi@redhat.com>
Date: Apr 01 2018 07:14:10 +0000
Subject: [PATCH 3/3] Fix a few E722 code styles errors


Signed-off-by: Chenxiong Qi <cqi@redhat.com>

---

diff --git a/fedpkg/__init__.py b/fedpkg/__init__.py
index dd1c2d9..298064d 100644
--- a/fedpkg/__init__.py
+++ b/fedpkg/__init__.py
@@ -166,7 +166,7 @@ class Commands(pyrpkg.Commands):
             try:
                 rawhidetarget = self.anon_kojisession.getBuildTarget(
                     'rawhide')
-            except:
+            except Exception:
                 # We couldn't hit koji, bail.
                 raise pyrpkg.rpkgError('Unable to query koji to find rawhide \
                                        target')
@@ -178,7 +178,7 @@ class Commands(pyrpkg.Commands):
         """
         try:
             runtime_os, runtime_version, _ = platform.linux_distribution()
-        except:
+        except Exception:
             return None
 
         if runtime_os in ['redhat', 'centos']:
diff --git a/fedpkg/__main__.py b/fedpkg/__main__.py
index 31c2ade..e12f255 100644
--- a/fedpkg/__main__.py
+++ b/fedpkg/__main__.py
@@ -60,7 +60,7 @@ def main():
     if not client.args.path:
         try:
             client.args.path = pyrpkg.utils.getcwd()
-        except:
+        except Exception:
             print('Could not get current path, have you deleted it?')
             sys.exit(1)
 

