Skip to content

Commit

Permalink
Remove dependency on legacy mock package and other Python2isms
Browse files Browse the repository at this point in the history
  • Loading branch information
webbnh committed Sep 27, 2024
1 parent 44d7d8d commit c2dd6dd
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 51 deletions.
11 changes: 2 additions & 9 deletions sync2jira/upstream_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@
# Authors: Ralph Bean <[email protected]>

import logging

try:
from urllib.parse import urlencode # py3
string_type = str
except ImportError:
from urllib import urlencode # py2
import types
string_type = types.StringTypes
from urllib.parse import urlencode

import requests
from github import Github
Expand Down Expand Up @@ -136,7 +129,7 @@ def handle_pagure_message(msg, config):
# Some messages send tags as strings, others as dicts. Handle both.
actual = \
[tag['name'] for tag in actual if isinstance(tag, dict)] + \
[tag for tag in actual if isinstance(tag, string_type)]
[tag for tag in actual if isinstance(tag, str)]

intersection = set(actual) & set(expected)
if not intersection:
Expand Down
6 changes: 0 additions & 6 deletions sync2jira/upstream_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@

import logging

try:
string_type = str
except ImportError:
import types
string_type = types.StringTypes

from github import Github

import sync2jira.intermediary as i
Expand Down
3 changes: 1 addition & 2 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
python-coveralls
coverage
pytest
pytest-cov
mock
python-coveralls
8 changes: 2 additions & 6 deletions tests/test_downstream_issue.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import mock
import unittest
try:
# Python 3.3 >
from unittest.mock import MagicMock # noqa: F401
except ImportError:
from mock import MagicMock # noqa: F401
import unittest.mock as mock
from unittest.mock import MagicMock
from datetime import datetime

import sync2jira.downstream_issue as d
Expand Down
8 changes: 2 additions & 6 deletions tests/test_downstream_pr.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import unittest
import mock
try:
# Python 3.3 >
from unittest.mock import MagicMock # noqa: F401
except ImportError:
from mock import MagicMock # noqa: F401
import unittest.mock as mock
from unittest.mock import MagicMock

import sync2jira.downstream_pr as d

Expand Down
3 changes: 1 addition & 2 deletions tests/test_intermediary.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from datetime import datetime
import mock
import unittest
import unittest.mock as mock

import sync2jira.intermediary as i

Expand Down
8 changes: 2 additions & 6 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import mock
import unittest
try:
# Python 3.3 >
from unittest.mock import MagicMock # noqa: F401
except ImportError:
from mock import MagicMock # noqa: F401
import unittest.mock as mock
from unittest.mock import MagicMock

import sync2jira.main as m

Expand Down
9 changes: 2 additions & 7 deletions tests/test_upstream_issue.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import mock
import unittest
try:
# Python 3.3 >
from unittest.mock import MagicMock # noqa: F401
except ImportError:
from mock import MagicMock # noqa: F401

import unittest.mock as mock
from unittest.mock import MagicMock

import sync2jira.upstream_issue as u

Expand Down
9 changes: 2 additions & 7 deletions tests/test_upstream_pr.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import mock
import unittest
try:
# Python 3.3 >
from unittest.mock import MagicMock # noqa: F401
except ImportError:
from mock import MagicMock # noqa: F401

import unittest.mock as mock
from unittest.mock import MagicMock

import sync2jira.upstream_pr as u

Expand Down

0 comments on commit c2dd6dd

Please sign in to comment.