1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-09-08 05:58:43 +02:00

Clean imports up, drop python 2 fallbacks

This commit is contained in:
2022-07-28 12:28:33 +02:00
parent e16e196fa1
commit 229913a77f
36 changed files with 216 additions and 335 deletions

View File

@@ -1,9 +1,12 @@
import osc.core
import osc.oscerr
import os
import sys
import osc.core
import osc.oscerr
from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'addfile_fixtures')
def suite():

View File

@@ -1,20 +1,13 @@
import osc.core
import osc.oscerr
import os
import sys
from urllib.error import HTTPError
from xml.etree import ElementTree as ET
import osc.core
import osc.oscerr
from .common import GET, PUT, POST, DELETE, OscTestCase
try:
# Works up to Python 3.8, needed for Python < 3.3 (inc 2.7)
from xml.etree import cElementTree as ET
except ImportError:
# will import a fast implementation from 3.3 onwards, needed
# for 3.9+
from xml.etree import ElementTree as ET
try:
from urllib.error import HTTPError
except ImportError:
#python 2.x
from urllib2 import HTTPError
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'commit_fixtures')

View File

@@ -1,8 +1,8 @@
import unittest
from osc.core import parseRevisionOption
from osc.oscerr import OscInvalidRevision
import unittest
class TestParseRevisionOption(unittest.TestCase):
def test_empty(self):

View File

@@ -1,8 +1,11 @@
import os
import osc.core
import osc.oscerr
import os
from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'deletefile_fixtures')
def suite():

View File

@@ -1,10 +1,13 @@
import os
import re
import osc.core
import osc.oscerr
from osc.util.helper import decode_list
import os
import re
from .common import GET, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'difffile_fixtures')
def suite():

View File

@@ -1,6 +1,8 @@
import unittest
from osc.util.helper import decode_it, decode_list
def suite():
return unittest.makeSuite(TestResults)

View File

@@ -1,7 +1,11 @@
import os
import osc.core
import osc.oscerr
import os
from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'init_package_fixtures')
def suite():

View File

@@ -1,7 +1,11 @@
import os
import osc.core
import osc.oscerr
import os
from .common import GET, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'init_project_fixtures')
def suite():

View File

@@ -1,8 +1,11 @@
import os
import osc.core
import osc.oscerr
import os
from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'project_package_status_fixtures')
def suite():

View File

@@ -1,9 +1,11 @@
import osc.commandline
import osc.core
import osc.oscerr
import os
import re
import sys
import osc.commandline
import osc.core
import osc.oscerr
from .common import GET, POST, OscTestCase, EXPECTED_REQUESTS

View File

@@ -1,8 +1,11 @@
import os
import osc.core
import osc.oscerr
import os
from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'project_package_status_fixtures')
def suite():

View File

@@ -1,15 +1,13 @@
import osc.core
import osc.oscerr
import os
import sys
from xml.etree import ElementTree as ET
import osc.core
import osc.oscerr
from .common import GET, PUT, POST, DELETE, OscTestCase
try:
# Works up to Python 3.8, needed for Python < 3.3 (inc 2.7)
from xml.etree import cElementTree as ET
except ImportError:
# will import a fast implementation from 3.3 onwards, needed
# for 3.9+
from xml.etree import ElementTree as ET
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'repairwc_fixtures')
def suite():

View File

@@ -1,16 +1,12 @@
try:
# Works up to Python 3.8, needed for Python < 3.3 (inc 2.7)
from xml.etree import cElementTree as ET
except ImportError:
# will import a fast implementation from 3.3 onwards, needed
# for 3.9+
from xml.etree import ElementTree as ET
import os
from xml.etree import ElementTree as ET
import osc.core
import osc.oscerr
import os
from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'request_fixtures')
def suite():

View File

@@ -1,8 +1,11 @@
import osc.commandline
from .common import GET, OscTestCase
import os
import sys
import osc.commandline
from .common import GET, OscTestCase
def suite():
import unittest
return unittest.makeSuite(TestResults)

View File

@@ -1,8 +1,11 @@
import os
import osc.core
import osc.oscerr
import os
from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'revertfile_fixtures')
def suite():

View File

@@ -1,7 +1,11 @@
import os
import osc.core
import osc.oscerr
import os
from .common import GET, PUT, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'setlinkrev_fixtures')
def suite():
@@ -60,10 +64,7 @@ class TestSetLinkRev(OscTestCase):
@GET('http://localhost/source/srcprj/srcpkg?rev=latest&expand=1', text='conflict in file merge', code=400)
def test_linkerror(self):
"""link is broken"""
try:
from urllib.error import HTTPError
except ImportError:
from urllib2 import HTTPError
from urllib.error import HTTPError
# the backend returns status 400 if we try to expand a broken _link
self.assertRaises(HTTPError, osc.core.set_link_rev, 'http://localhost', 'osctest', 'simple', expand=True)

View File

@@ -1,8 +1,12 @@
import osc.core
import osc.oscerr
import os
import sys
import osc.core
import osc.oscerr
from .common import GET, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'update_fixtures')
def suite():