Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3532356
Prepare for futurize pass: fix "except" clause
ydirson Jul 28, 2022
3ee5615
Futurize: first pass, using -wn1
ydirson Aug 11, 2022
8ef7288
Futurize fixes: drop now-duplicated test
ydirson Jul 28, 2022
ddf7ba6
Futurize fixes: fix broken indentations
ydirson Jul 12, 2022
d97f4aa
Futurize fixes: use "raise" not "raise_" when not reraising
ydirson Jul 12, 2022
d05898a
Un-futurize: replace future.utils.raise_ with six.raise_from
ydirson Jul 15, 2022
459f5ef
Futurize fixes: remove now-unused imports
ydirson Jul 12, 2022
6505b3f
Futurize pylint complements: "print" continuation indentations, line …
ydirson Jul 15, 2022
7ae43d5
Futurize pylint complements: whitespace in expressions
ydirson Jul 15, 2022
a88ceb5
Migrate tests from StringIO.StringIO to io.StringIO
ydirson Jul 15, 2022
4d3681c
cpiofile: drop CpioFileCompat.write()
ydirson Jul 29, 2022
8a29168
Switch integer division to py3-compatible "//"
ydirson Jul 15, 2022
c410bab
xcp.accessor: upgrade urllib usage (futurize)
ydirson Jul 18, 2022
60ecacd
xcp.accessor: more urllib upgrading
ydirson Jul 18, 2022
422993d
Use new-style classes even in python2 (2to3)
ydirson Jul 18, 2022
764fc9b
futurize: deal with xrange()
ydirson Jul 18, 2022
4728f42
python3: remove casts from "int" to "long"
ydirson Jul 18, 2022
05e65da
python3: change float cast from "long" to "int"
ydirson Jul 18, 2022
bd10129
2to3: rename "next" methods to "__next__", use six.Iterator for porta…
ydirson Jul 18, 2022
1b54918
futurize: convert "iteritems()" to "items()", all negligible perf impact
ydirson Jul 18, 2022
48f6d6b
Apply fixes from `2to3 -f map` that are useful even when suboptimal
ydirson Jul 18, 2022
e67cf34
Apply all fixes from `2to3 -f filter` that are useful even when subop…
ydirson Jul 18, 2022
eede266
Futurize fixes: use generator comprehensions when list ones are not n…
ydirson Jul 18, 2022
610144a
Futurize cleanups: use list comprehension not `list(map())` or `list(…
ydirson Jul 18, 2022
7b03e6a
Futurize cleanups: xcp.net.ifrename.logic: simplify nested comprehens…
ydirson Jul 18, 2022
62bb70a
Futurize cleanups: line-wrapping fixes
ydirson Jul 18, 2022
1a33f75
Futurize cleanups: cleanup duplicated imports
ydirson Jul 18, 2022
e3dd1cc
Futurize pylint complements: xcp.accessor: bring consistency to "open…
ydirson Jul 20, 2022
60f35c5
Futurize pylint complements: disable warnings triggered by "import fu…
ydirson Jul 20, 2022
b12aa7c
Futurize pylint complements: test_cpio: mark unused import as expected
ydirson Jul 20, 2022
6d14ba8
Futurize pylint complements: xcp.accessor: avoid redefining "file" bu…
ydirson Jul 20, 2022
a78340c
Futurize pylint complements: Avoid useless ".keys()" when enumerating…
ydirson Jul 20, 2022
5da778b
Futurize pylint complements: xcp.repository: honor singleton-comparis…
ydirson Jul 20, 2022
e6b3689
Futurize pylint complements: xcp.repository: locally disable too-few-…
ydirson Jul 20, 2022
3d35879
Futurize pylint complements: "print" continuation indentations, line …
ydirson Jul 15, 2022
84a013f
Futurize pylint complements: whitespace in expressions
ydirson Jul 15, 2022
4cd6d2b
xcp.cpiofile: fix bad indentation
ydirson Aug 8, 2022
0ccda70
xcp: get rid of useless blackslash line continuations
ydirson Aug 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ diff_cover
mock
pytest
pytest-cov
# dependencies also in setup.py until they can be used
six
future
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@
],
requires=[
'branding',
'six',
'future',
],
)
8 changes: 5 additions & 3 deletions tests/test_cpio.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import os
import shutil
import subprocess
Expand Down Expand Up @@ -45,8 +46,9 @@ def setUp(self):
check_call("gzip -c < archive.cpio > archive.cpio.gz")
check_call("bzip2 -c < archive.cpio > archive.cpio.bz2")
try:
import lzma
self.doXZ = subprocess.call("xz --check=crc32 --lzma2=dict=1MiB < archive.cpio > archive.cpio.xz", shell=True) == 0
import lzma # pylint: disable=unused-variable
self.doXZ = subprocess.call("xz --check=crc32 --lzma2=dict=1MiB"
" < archive.cpio > archive.cpio.xz", shell=True) == 0
except Exception as ex:
# FIXME will issue warning even if test_xz is not requested
warnings.warn("will not test cpio.xz: %s" % ex)
Expand Down Expand Up @@ -113,7 +115,7 @@ def test_bz2(self):
def test_xz(self):
if not self.doXZ:
raise unittest.SkipTest("lzma package or xz tool not available")
print 'Running test for XZ'
print('Running test for XZ')
self.doArchive('archive.cpio.xz', 'xz')

# CpioFileCompat testing
Expand Down
22 changes: 10 additions & 12 deletions tests/test_ifrename_dynamic.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from __future__ import unicode_literals
import json
import logging
import unittest
from copy import deepcopy

try:
import cStringIO as StringIO
except ImportError:
import StringIO
from io import StringIO

from xcp.net.ifrename.dynamic import DynamicRules
from xcp.net.ifrename.macpci import MACPCI
Expand All @@ -16,7 +14,7 @@
class TestLoadAndParse(unittest.TestCase):

def setUp(self):
self.logbuf = StringIO.StringIO()
self.logbuf = StringIO()
openLog(self.logbuf, logging.NOTSET)

def tearDown(self):
Expand All @@ -26,7 +24,7 @@ def tearDown(self):

def test_null(self):

fd = StringIO.StringIO("")
fd = StringIO("")
dr = DynamicRules(fd=fd)

self.assertTrue(dr.load_and_parse())
Expand All @@ -36,7 +34,7 @@ def test_null(self):

def test_empty(self):

fd = StringIO.StringIO(
fd = StringIO(
'{"lastboot":[],"old":[]}'
)
dr = DynamicRules(fd=fd)
Expand All @@ -48,7 +46,7 @@ def test_empty(self):

def test_one_invalid(self):

fd = StringIO.StringIO(
fd = StringIO(
'{"lastboot":[["","",""]],"old":[]}'
)
dr = DynamicRules(fd=fd)
Expand All @@ -60,7 +58,7 @@ def test_one_invalid(self):

def test_one_valid_lastboot(self):

fd = StringIO.StringIO(
fd = StringIO(
'{"lastboot":[["01:23:45:67:89:0a","00:10.2","eth2"]],"old":[]}'
)
dr = DynamicRules(fd=fd)
Expand All @@ -74,7 +72,7 @@ def test_one_valid_lastboot(self):

def test_one_valid_lastboot2(self):

fd = StringIO.StringIO(
fd = StringIO(
'{"lastboot":[],"old":[["01:23:45:67:89:0a","00:10.2","eth2"]]}'
)
dr = DynamicRules(fd=fd)
Expand All @@ -88,7 +86,7 @@ def test_one_valid_lastboot2(self):
class TestGenerate(unittest.TestCase):

def setUp(self):
self.logbuf = StringIO.StringIO()
self.logbuf = StringIO()
openLog(self.logbuf, logging.NOTSET)

def tearDown(self):
Expand Down Expand Up @@ -149,7 +147,7 @@ def test_pci_missing(self):
class TestSave(unittest.TestCase):

def setUp(self):
self.logbuf = StringIO.StringIO()
self.logbuf = StringIO()
openLog(self.logbuf, logging.NOTSET)

def tearDown(self):
Expand Down
41 changes: 20 additions & 21 deletions tests/test_ifrename_logic.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from __future__ import print_function
from __future__ import unicode_literals
import logging
import sys
import unittest
from copy import deepcopy

try:
import cStringIO as StringIO
except ImportError:
import StringIO
from io import StringIO

from xcp.net.ifrename.logic import *
from xcp.logger import LOG, openLog, closeLogs
Expand Down Expand Up @@ -34,7 +33,7 @@ def apply_transactions(lst, trans):
class TestSimpleLogic(unittest.TestCase):

def setUp(self):
self.siobuff = StringIO.StringIO()
self.siobuff = StringIO()
openLog(self.siobuff, logging.NOTSET)

def tearDown(self):
Expand All @@ -43,15 +42,15 @@ def tearDown(self):
self.siobuff.close()

def debug_state(self, ts):
print >>sys.stderr, ""
print >>sys.stderr, self.siobuff.getvalue()
print >>sys.stderr, ""
print("", file=sys.stderr)
print(self.siobuff.getvalue(), file=sys.stderr)
print("", file=sys.stderr)
if len(ts):
for (s,d) in ts:
print >>sys.stderr, "'%s' -> '%s'" % (s, d)
print("'%s' -> '%s'" % (s, d), file=sys.stderr)
else:
print >>sys.stderr, "No transactions"
print >>sys.stderr, ""
print("No transactions", file=sys.stderr)
print("", file=sys.stderr)


def test_newhw_norules_1eth(self):
Expand Down Expand Up @@ -259,7 +258,7 @@ def test_1drule_1eth_already_complete(self):
class TestUseCases(unittest.TestCase):

def setUp(self):
self.siobuff = StringIO.StringIO()
self.siobuff = StringIO()
openLog(self.siobuff, logging.NOTSET)

def tearDown(self):
Expand All @@ -268,16 +267,16 @@ def tearDown(self):
self.siobuff.close()

def debug_state(self, ts):
print >>sys.stderr, ""
print >>sys.stderr, self.siobuff.getvalue()
print >>sys.stderr, ""
print("", file=sys.stderr)
print(self.siobuff.getvalue(), file=sys.stderr)
print("", file=sys.stderr)
if len(ts):
print >>sys.stderr, "Transactions:"
print("Transactions:", file=sys.stderr)
for (s,d) in ts:
print >>sys.stderr, "'%s' -> '%s'" % (s, d)
print("'%s' -> '%s'" % (s, d), file=sys.stderr)
else:
print >>sys.stderr, "No transactions"
print >>sys.stderr, ""
print("No transactions", file=sys.stderr)
print("", file=sys.stderr)

def test_usecase1(self):
"""
Expand Down Expand Up @@ -533,7 +532,7 @@ def setUp(self):
set to None and a tname set to the 'eth'
"""

self.siobuff = StringIO.StringIO()
self.siobuff = StringIO()
openLog(self.siobuff)


Expand All @@ -559,7 +558,7 @@ def assertNotRaises(self, excp, fn, *argl, **kwargs):
"""Because unittest.TestCase seems to be missing this functionality"""
try:
fn(*argl, **kwargs)
except excp, e:
except excp as e:
self.fail("function raised %s unexpectedly: %s"
% (excp, e))

Expand Down
Loading