1
0
mirror of https://github.com/vikstrous/pirate-get synced 2025-01-10 10:04:21 +01:00

Merge pull request #87 from vikstrous/version-check

move version check to setup.py
This commit is contained in:
Michele Guerini Rocco 2016-07-06 13:19:15 +02:00 committed by GitHub
commit ea8a2f5d2f
3 changed files with 41 additions and 34 deletions

View File

@ -1,9 +1,4 @@
import sys
from distutils.version import LooseVersion
if LooseVersion(sys.version) < LooseVersion("3.4.0"):
print("At least python 3.4.0 required. Your version is "+sys.version)
sys.exit(1)
import re
import os
import argparse

View File

@ -1,6 +1,14 @@
#!/usr/bin/env python3
from setuptools import setup, find_packages
from distutils.version import LooseVersion
import sys
if LooseVersion(sys.version) < LooseVersion("3.4.0"):
print("pirate-get requires at least python 3.4.0."
" Your version is %s." % sys.version.split()[0])
sys.exit(1)
if __name__ == '__main__':
setup(name='pirate-get',
version='0.2.8',
description='A command line interface for The Pirate Bay',
@ -13,7 +21,9 @@ setup(name='pirate-get',
entry_points={
'console_scripts': ['pirate-get = pirate.pirate:main']
},
install_requires=['colorama>=0.3.3', 'beautifulsoup4>=4.4.1', 'veryprettytable>=0.8.1'],
install_requires=['colorama>=0.3.3',
'beautifulsoup4>=4.4.1',
'veryprettytable>=0.8.1'],
keywords=['torrent', 'magnet', 'download', 'tpb', 'client'],
classifiers=[
'Topic :: Utilities',
@ -23,5 +33,4 @@ setup(name='pirate-get',
'Programming Language :: Python :: 3.4',
'License :: OSI Approved :: GNU General Public License (GPL)',
],
test_suite='tests',
)
test_suite='tests')

View File

@ -1,37 +1,40 @@
#!/usr/bin/env python3
import sys
import os.path
import unittest
import importlib
from unittest import mock
from unittest.mock import patch, call, MagicMock
import pirate.pirate
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import setup
class TestPirate(unittest.TestCase):
@patch('sys.exit')
def test_unsupported(self, mock_exit):
sys.version = '3.2.1 (default, dec 7 2015, 12:58:09) \n[gcc 5.2.0]'
importlib.reload(pirate.pirate)
importlib.reload(setup)
mock_exit.assert_called_once_with(1)
@patch('sys.exit')
def test_unsupported2(self, mock_exit):
sys.version = '2.5.1 (default, dec 7 2015, 12:58:09) \n[gcc 5.2.0]'
importlib.reload(pirate.pirate)
importlib.reload(setup)
mock_exit.assert_called_once_with(1)
@patch('sys.exit')
def test_supported(self, mock_exit):
sys.version = '3.5.1 (default, dec 7 2015, 12:58:09) \n[gcc 5.2.0]'
importlib.reload(pirate.pirate)
importlib.reload(setup)
mock_exit.assert_not_called()
@patch('sys.exit')
def test_supported_exact(self, mock_exit):
sys.version = '3.4.0 (default, dec 7 2015, 12:58:09) \n[gcc 5.2.0]'
importlib.reload(pirate.pirate)
importlib.reload(setup)
mock_exit.assert_not_called()
if __name__ == '__main__':