aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--setup.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/setup.py b/setup.py
index a2a75504..681b9031 100644
--- a/setup.py
+++ b/setup.py
@@ -11,10 +11,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
+import sys
from distutils.command.build import build
from setuptools import setup, find_packages
-
+from setuptools.command.test import test as TestCommand
base_dir = os.path.dirname(__file__)
@@ -31,6 +32,12 @@ requirements = [
SIX_DEPENDENCY
]
+test_requirements = [
+ "pytest",
+ "pretend",
+ "iso8601"
+]
+
class CFFIBuild(build):
"""
@@ -64,6 +71,19 @@ class CFFIBuild(build):
build.finalize_options(self)
+class PyTest(TestCommand):
+ def finalize_options(self):
+ TestCommand.finalize_options(self)
+ self.test_args = []
+ self.test_suite = True
+
+ def run_tests(self):
+ # Import here because in module scope the eggs are not loaded.
+ import pytest
+ errno = pytest.main(self.test_args)
+ sys.exit(errno)
+
+
with open(os.path.join(base_dir, "README.rst")) as f:
long_description = f.read()
@@ -105,11 +125,13 @@ setup(
install_requires=requirements,
setup_requires=requirements,
+ tests_require=test_requirements,
# for cffi
zip_safe=False,
ext_package="cryptography",
cmdclass={
"build": CFFIBuild,
+ "test": PyTest,
}
)
a id='n167' href='#n167'>167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
from os.path import dirname, join
import json

# Try to load JSON data from a file. If not found, use the argument as a tag name and retrieve the data from GitHub.
def getJSON(tag='all'):
   f = tag
   tag = '/'+tag
   if f == 'all':
      f = 'releases'
      tag = ''

   try:
      d = json.loads(open(join(dirname(__file__), f+'.json'), 'r').read())
   except:
      from urllib.request import urlopen
      d = json.loads(urlopen('https://api.github.com/repos/ghdl/ghdl/releases'+tag).read())
      json.dump(d, open(f+'.json', 'w'), indent=4)
   return d