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

move version check to setup.py

This commit is contained in:
rnhmjoj 2016-07-04 13:16:42 +02:00
parent 7deac793b5
commit 867333db87
No known key found for this signature in database
GPG Key ID: 362BB82B7E496B7C
3 changed files with 41 additions and 34 deletions

View File

@ -1,9 +1,4 @@
import sys 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 re
import os import os
import argparse import argparse

View File

@ -1,6 +1,14 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from setuptools import setup, find_packages 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', setup(name='pirate-get',
version='0.2.8', version='0.2.8',
description='A command line interface for The Pirate Bay', description='A command line interface for The Pirate Bay',
@ -13,7 +21,9 @@ setup(name='pirate-get',
entry_points={ entry_points={
'console_scripts': ['pirate-get = pirate.pirate:main'] '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'], keywords=['torrent', 'magnet', 'download', 'tpb', 'client'],
classifiers=[ classifiers=[
'Topic :: Utilities', 'Topic :: Utilities',
@ -23,5 +33,4 @@ setup(name='pirate-get',
'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.4',
'License :: OSI Approved :: GNU General Public License (GPL)', 'License :: OSI Approved :: GNU General Public License (GPL)',
], ],
test_suite='tests', test_suite='tests')
)

View File

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