Skip to content

Commit 31726ea

Browse files
committed
switch to python 3.10
1 parent c471e63 commit 31726ea

File tree

9 files changed

+24
-20
lines changed

9 files changed

+24
-20
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2.0
33
jobs:
44
build:
55
docker:
6-
- image: cimg/python:2.7-browsers
6+
- image: cimg/python:3.10-browsers
77
steps:
88
- run: sudo apt update && sudo apt-get install pylint
99
- checkout

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
steps:
1111
- uses: actions/setup-python@v4
1212
with:
13-
python-version: 2.7
13+
python-version: "3.10"
1414
- name: Setup build tools
1515
run: |
1616
sudo apt-get install pylint

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
__pycache__
2+
.venv
23
.ropeproject
34
*.swp
45
*.pyc

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Publishing **Test Content** using www.testspace.com.
2929

3030
***
3131

32-
In order to run this sample you will need a host workstation with installed python 2.6+.
32+
In order to run this sample you will need a host workstation with installed python 3.8+.
3333

3434

3535
Download and configure the Testspace client

requirements.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
cov-core
2-
enum
3-
mock==2.0.0
1+
mock
42
nose2
5-
six==1.10.0
6-
unittest2
3+
nose2-cov
4+
six

stock_alerter/tests/test_action.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import print_function
22
import smtplib
3-
import unittest2 as unittest
3+
import unittest
44
import mock
55

66
from ..action import EmailAction, PrintAction
@@ -28,7 +28,7 @@ def __eq__(self, other):
2828
self.expected["Message"] == other._payload
2929

3030

31-
@mock.patch("__builtin__.print")
31+
@mock.patch("stock_alerter.action.print")
3232
class PrintActionTest(unittest.TestCase):
3333
def test_executing_action_prints_message(self, mock_print):
3434
action = PrintAction()

stock_alerter/tests/test_legacy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, exchange):
1212

1313

1414
class AlertProcessorTest(unittest.TestCase):
15-
@mock.patch("__builtin__.print")
15+
@mock.patch("stock_alerter.legacy.print")
1616
def test_processor_characterization_1(self, mock_print):
1717
AlertProcessor()
1818
mock_print.assert_has_calls([mock.call("AAPL", 8),
@@ -22,7 +22,7 @@ def test_processor_characterization_1(self, mock_print):
2222

2323
def test_processor_characterization_2(self):
2424
processor = AlertProcessor(autorun=False)
25-
with mock.patch("__builtin__.print") as mock_print:
25+
with mock.patch("stock_alerter.legacy.print") as mock_print:
2626
processor.run()
2727
mock_print.assert_has_calls([mock.call("AAPL", 8),
2828
mock.call("GOOG", 15),
@@ -72,7 +72,7 @@ def test_processor_characterization_7(self):
7272
processor.parse_file = mock.Mock()
7373
processor.parse_file.return_value = [
7474
('GOOG', datetime(2014, 2, 11, 14, 12, 22, 130000), 15)]
75-
with mock.patch("__builtin__.print") as mock_print:
75+
with mock.patch("stock_alerter.legacy.print") as mock_print:
7676
processor.run()
7777
mock_print.assert_called_with("GOOG", 15)
7878

@@ -81,7 +81,7 @@ def test_processor_characterization_8(self):
8181
processor.parse_file = mock.Mock()
8282
processor.parse_file.return_value = [
8383
('GOOG', datetime(2014, 2, 11, 14, 10, 22, 130000), 5)]
84-
with mock.patch("__builtin__.print") as mock_print:
84+
with mock.patch("stock_alerter.legacy.print") as mock_print:
8585
processor.run()
8686
self.assertFalse(mock_print.called)
8787

stock_alerter/tests/test_reader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get_update(data):
1717
class FileReaderTest(unittest.TestCase):
1818
def test_FileReader_opens_the_given_file(self):
1919
mock_open = mock.mock_open(read_data="")
20-
with mock.patch("__builtin__.open", mock_open, create=True):
20+
with mock.patch("stock_alerter.reader.open", mock_open, create=True):
2121
reader = FileReader("stocks.txt")
2222
updater = reader.get_updates()
2323
self.get_update(updater)
@@ -30,7 +30,7 @@ def get_update(data):
3030
except StopIteration:
3131
pass
3232

33-
@mock.patch("__builtin__.open",
33+
@mock.patch("stock_alerter.reader.open",
3434
mock.mock_open(read_data="""\
3535
GOOG,2014-02-11T14:10:22.13,10"""))
3636
def test_FileReader_returns_the_file_contents(self):
@@ -41,7 +41,7 @@ def test_FileReader_returns_the_file_contents(self):
4141
datetime(2014, 2, 11, 14, 10, 22, 130000),
4242
10), update)
4343

44-
@mock.patch("__builtin__.open",
44+
@mock.patch("stock_alerter.reader.open",
4545
mock.mock_open(read_data="""\
4646
GOOG,2014-02-11T14:10:22.13,10
4747
MSFT,2014-02-11T00:00:00.0,8"""))

stock_alerter/tests/test_stock.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
import unittest2 as unittest
1+
import unittest
22
import collections
33
from datetime import datetime, timedelta
44

55
from ..stock import Stock, StockSignal
66

7+
try:
8+
from collections.abc import Iterable
9+
except ImportError:
10+
from collections import Iterable
11+
712

813
class StockTest(unittest.TestCase):
914
def setUp(self):
@@ -55,14 +60,14 @@ def setUp(self):
5560

5661
def _flatten(self, timestamps):
5762
for timestamp in timestamps:
58-
if not isinstance(timestamp, collections.Iterable):
63+
if not isinstance(timestamp, Iterable):
5964
yield timestamp
6065
else:
6166
for value in self._flatten(timestamp):
6267
yield value
6368

6469
def _generate_timestamp_for_date(self, date, price_list):
65-
if not isinstance(price_list, collections.Iterable):
70+
if not isinstance(price_list, Iterable):
6671
return date
6772
else:
6873
delta = 1.0/len(price_list)

0 commit comments

Comments
 (0)