1
0
mirror of https://github.com/vikstrous/pirate-get synced 2025-01-09 09:59:51 +01:00
pirate-get/tests/test_version.py

42 lines
1.2 KiB
Python
Raw Permalink Normal View History

2016-01-04 00:05:58 +01:00
#!/usr/bin/env python3
import sys
2016-07-04 13:16:42 +02:00
import os.path
2016-01-04 00:05:58 +01:00
import unittest
import importlib
from unittest import mock
from unittest.mock import patch, call, MagicMock
2016-07-04 13:16:42 +02:00
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import setup
2016-01-04 00:05:58 +01:00
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]'
2016-07-04 13:16:42 +02:00
importlib.reload(setup)
2016-01-04 00:05:58 +01:00
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]'
2016-07-04 13:16:42 +02:00
importlib.reload(setup)
2016-01-04 00:05:58 +01:00
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]'
2016-07-04 13:16:42 +02:00
importlib.reload(setup)
2016-01-04 00:05:58 +01:00
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]'
2016-07-04 13:16:42 +02:00
importlib.reload(setup)
2016-01-04 00:05:58 +01:00
mock_exit.assert_not_called()
if __name__ == '__main__':
unittest.main()