Merge "Adjust hacking tests to fix py38 support"
This commit is contained in:
commit
253d3359e6
@ -16,6 +16,7 @@
|
|||||||
import decimal
|
import decimal
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
|
import flask
|
||||||
from keystoneauth1 import session as ks_sess
|
from keystoneauth1 import session as ks_sess
|
||||||
from oslo_config import fixture as config_fixture
|
from oslo_config import fixture as config_fixture
|
||||||
from oslotest import base
|
from oslotest import base
|
||||||
@ -84,9 +85,13 @@ class TestCase(testscenarios.TestWithScenarios, base.BaseTestCase):
|
|||||||
return_value=ks_sess.Session())
|
return_value=ks_sess.Session())
|
||||||
session.start()
|
session.start()
|
||||||
self.session = session
|
self.session = session
|
||||||
|
self.app = flask.Flask('cloudkitty')
|
||||||
|
self.app_context = self.app.test_request_context()
|
||||||
|
self.app_context.push()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
db.get_engine().dispose()
|
db.get_engine().dispose()
|
||||||
self.auth.stop()
|
self.auth.stop()
|
||||||
self.session.stop()
|
self.session.stop()
|
||||||
|
self.app_context.pop()
|
||||||
super(TestCase, self).tearDown()
|
super(TestCase, self).tearDown()
|
||||||
|
@ -12,14 +12,15 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
import unittest
|
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from cloudkitty.api.v2.dataframes import dataframes
|
from cloudkitty.api.v2.dataframes import dataframes
|
||||||
|
from cloudkitty import tests
|
||||||
|
|
||||||
from cloudkitty.utils import tz as tzutils
|
from cloudkitty.utils import tz as tzutils
|
||||||
|
|
||||||
|
|
||||||
class TestDataframeListEndpoint(unittest.TestCase):
|
class TestDataframeListEndpoint(tests.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestDataframeListEndpoint, self).setUp()
|
super(TestDataframeListEndpoint, self).setUp()
|
||||||
|
@ -12,14 +12,15 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
import unittest
|
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from cloudkitty.api.v2.summary import summary
|
from cloudkitty.api.v2.summary import summary
|
||||||
|
from cloudkitty import tests
|
||||||
|
|
||||||
from cloudkitty.utils import tz as tzutils
|
from cloudkitty.utils import tz as tzutils
|
||||||
|
|
||||||
|
|
||||||
class TestSummaryEndpoint(unittest.TestCase):
|
class TestSummaryEndpoint(tests.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestSummaryEndpoint, self).setUp()
|
super(TestSummaryEndpoint, self).setUp()
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import sys
|
|
||||||
import textwrap
|
import textwrap
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
@ -146,7 +145,7 @@ class HackingTestCase(tests.TestCase):
|
|||||||
"climbing.", ('volume1', 500))
|
"climbing.", ('volume1', 500))
|
||||||
"""
|
"""
|
||||||
self._assert_has_errors(code.format(log_method), checker,
|
self._assert_has_errors(code.format(log_method), checker,
|
||||||
expected_errors=[(4, 21, 'C310')])
|
expected_errors=[(4, mock.ANY, 'C310')])
|
||||||
|
|
||||||
def test_str_on_exception(self):
|
def test_str_on_exception(self):
|
||||||
|
|
||||||
@ -159,7 +158,7 @@ class HackingTestCase(tests.TestCase):
|
|||||||
p = str(e)
|
p = str(e)
|
||||||
return p
|
return p
|
||||||
"""
|
"""
|
||||||
errors = [(5, 16, 'C314')]
|
errors = [(5, mock.ANY, 'C314')]
|
||||||
self._assert_has_errors(code, checker, expected_errors=errors)
|
self._assert_has_errors(code, checker, expected_errors=errors)
|
||||||
|
|
||||||
def test_no_str_unicode_on_exception(self):
|
def test_no_str_unicode_on_exception(self):
|
||||||
@ -184,7 +183,7 @@ class HackingTestCase(tests.TestCase):
|
|||||||
p = unicode(e)
|
p = unicode(e)
|
||||||
return p
|
return p
|
||||||
"""
|
"""
|
||||||
errors = [(5, 20, 'C314')]
|
errors = [(5, mock.ANY, 'C314')]
|
||||||
self._assert_has_errors(code, checker, expected_errors=errors)
|
self._assert_has_errors(code, checker, expected_errors=errors)
|
||||||
|
|
||||||
def test_str_on_multiple_exceptions(self):
|
def test_str_on_multiple_exceptions(self):
|
||||||
@ -201,7 +200,7 @@ class HackingTestCase(tests.TestCase):
|
|||||||
p = e
|
p = e
|
||||||
return p
|
return p
|
||||||
"""
|
"""
|
||||||
errors = [(8, 20, 'C314'), (8, 29, 'C314')]
|
errors = [(8, mock.ANY, 'C314'), (8, mock.ANY, 'C314')]
|
||||||
self._assert_has_errors(code, checker, expected_errors=errors)
|
self._assert_has_errors(code, checker, expected_errors=errors)
|
||||||
|
|
||||||
def test_str_unicode_on_multiple_exceptions(self):
|
def test_str_unicode_on_multiple_exceptions(self):
|
||||||
@ -218,7 +217,9 @@ class HackingTestCase(tests.TestCase):
|
|||||||
p = str(e)
|
p = str(e)
|
||||||
return p
|
return p
|
||||||
"""
|
"""
|
||||||
errors = [(8, 20, 'C314'), (8, 33, 'C314'), (9, 16, 'C314')]
|
errors = [(8, mock.ANY, 'C314'),
|
||||||
|
(8, mock.ANY, 'C314'),
|
||||||
|
(9, mock.ANY, 'C314')]
|
||||||
self._assert_has_errors(code, checker, expected_errors=errors)
|
self._assert_has_errors(code, checker, expected_errors=errors)
|
||||||
|
|
||||||
def test_trans_add(self):
|
def test_trans_add(self):
|
||||||
@ -238,13 +239,9 @@ class HackingTestCase(tests.TestCase):
|
|||||||
return msg
|
return msg
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Python 3.4.0 introduced a change to the column calculation during AST
|
# We don't assert on specific column numbers since there is a small
|
||||||
# parsing. This was reversed in Python 3.4.3, hence the version-based
|
# change in calculation between <py38 and >=py38
|
||||||
# expected value calculation. See #1499743 for more background.
|
errors = [(9, mock.ANY, 'C315'), (10, mock.ANY, 'C315')]
|
||||||
if sys.version_info < (3, 4, 0) or sys.version_info >= (3, 4, 3):
|
|
||||||
errors = [(9, 10, 'C315'), (10, 24, 'C315')]
|
|
||||||
else:
|
|
||||||
errors = [(9, 11, 'C315'), (10, 25, 'C315')]
|
|
||||||
self._assert_has_errors(code, checker, expected_errors=errors)
|
self._assert_has_errors(code, checker, expected_errors=errors)
|
||||||
|
|
||||||
code = """
|
code = """
|
||||||
|
Loading…
Reference in New Issue
Block a user