From e52cd73cce5cd2d6dc1bccccbdc34529753fdc56 Mon Sep 17 00:00:00 2001 From: Matt Lewellyn Date: Wed, 26 Oct 2022 13:23:28 -0700 Subject: [PATCH] update package setup and CI, remove some old deprecations --- .circleci/pytest.ini | 20 +++++ blazeutils/__init__.py | 2 - blazeutils/config.py | 3 - blazeutils/containers.py | 8 +- blazeutils/datastructures.py | 3 - blazeutils/dates.py | 3 - blazeutils/decorators.py | 11 +-- blazeutils/error_handling.py | 31 ------- blazeutils/filesystem.py | 3 - blazeutils/functional.py | 9 +- blazeutils/helpers.py | 6 +- blazeutils/importing.py | 4 +- blazeutils/numbers.py | 6 -- blazeutils/rst.py | 9 +- blazeutils/sentinels.py | 3 - blazeutils/spreadsheets.py | 3 - blazeutils/strings.py | 8 +- blazeutils/testing.py | 88 +------------------ blazeutils/tests/test_config.py | 2 - blazeutils/tests/test_containers.py | 5 +- blazeutils/tests/test_datastructures.py | 6 +- blazeutils/tests/test_datetime.py | 3 - blazeutils/tests/test_decorators.py | 11 +-- blazeutils/tests/test_error_handling.py | 35 +------- blazeutils/tests/test_filesystem.py | 3 - blazeutils/tests/test_functional.py | 2 - blazeutils/tests/test_helpers.py | 3 - blazeutils/tests/test_importing.py | 3 - blazeutils/tests/test_numbers.py | 3 - blazeutils/tests/test_rst.py | 3 - blazeutils/tests/test_sentinels.py | 3 - blazeutils/tests/test_spreadsheets.py | 2 - blazeutils/tests/test_sqlalchemy.py | 5 -- blazeutils/tests/test_strings.py | 3 - blazeutils/tests/test_testing.py | 107 +----------------------- setup.py | 6 +- stable-requirements.txt | 33 ++++++++ tox.ini | 21 +++-- wheelhouse.ini | 6 -- 39 files changed, 94 insertions(+), 391 deletions(-) create mode 100644 stable-requirements.txt delete mode 100644 wheelhouse.ini diff --git a/.circleci/pytest.ini b/.circleci/pytest.ini index e69de29..f57f68e 100644 --- a/.circleci/pytest.ini +++ b/.circleci/pytest.ini @@ -0,0 +1,20 @@ +# This file's purpose is to keep a developer's local pytest.ini from interfering with tox +# tests as well as control turning warnings into errors. +[pytest] +junit_family=xunit2 +filterwarnings = + # Any errors not noted here should cause pytest to throw an error. It seems like this should be + # last in the list, but warnings that match multiple lines will apply the last line matched. + error + + # Example warning filters + + # We support openpyxl, but also maintain some xlrd support + ignore:xlrd is no longer maintained + + # DeprecationWarning should only be visible when testing with older libraries (i.e. "lowest" + # tests") -- https://github.com/level12/keg/issues/164 + ignore:.*soft_unicode + + # Flask version incompatability warning - https://github.com/level12/keg/issues/163 + ignore:The 'script_info' argument is deprecated diff --git a/blazeutils/__init__.py b/blazeutils/__init__.py index 50b36aa..0359bcd 100644 --- a/blazeutils/__init__.py +++ b/blazeutils/__init__.py @@ -1,6 +1,5 @@ # flake8: noqa -from __future__ import absolute_import from os import path as osp ## legacy imports, future imports should use the full import path @@ -8,7 +7,6 @@ HtmlAttributeHolder from blazeutils.dates import safe_strftime from blazeutils.decorators import decorator, curry -from blazeutils.error_handling import tb_depth_in, traceback_depth from blazeutils.filesystem import randfile from blazeutils.functional import posargs_limiter from blazeutils.helpers import tolist, toset, grouper, is_empty, is_iterable, \ diff --git a/blazeutils/config.py b/blazeutils/config.py index cd985a6..929e3bb 100644 --- a/blazeutils/config.py +++ b/blazeutils/config.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - import copy from blazeutils.datastructures import OrderedProperties, OrderedDict diff --git a/blazeutils/containers.py b/blazeutils/containers.py index f1e01ea..bacb50e 100644 --- a/blazeutils/containers.py +++ b/blazeutils/containers.py @@ -1,9 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - -import six - - class LazyDict(dict): def __init__(self, *args, **kwargs): self._ld_initialized = kwargs.pop('_ld_initialize', True) @@ -35,7 +29,7 @@ def __delattr__(self, name): del self[name] -class _Attribute(six.text_type): +class _Attribute(str): def __add__(self, other): return _Attribute('{0} {1}'.format(self, other).lstrip(' ')) diff --git a/blazeutils/datastructures.py b/blazeutils/datastructures.py index 37fbbb9..8995d87 100644 --- a/blazeutils/datastructures.py +++ b/blazeutils/datastructures.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - from blazeutils.containers import LazyDict # noqa from blazeutils.sentinels import NotGiven diff --git a/blazeutils/dates.py b/blazeutils/dates.py index 73873f0..a2d2ece 100644 --- a/blazeutils/dates.py +++ b/blazeutils/dates.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - import datetime as dt diff --git a/blazeutils/decorators.py b/blazeutils/decorators.py index 08a27a0..5b2ea66 100644 --- a/blazeutils/decorators.py +++ b/blazeutils/decorators.py @@ -1,7 +1,3 @@ -from __future__ import absolute_import -from __future__ import print_function -from __future__ import unicode_literals - import functools from functools import partial import inspect @@ -13,8 +9,6 @@ import warnings import wrapt -import six -from six.moves import range, map log = logging.getLogger(__name__) @@ -242,6 +236,7 @@ def wrapper(wrapped, instance, args, kwargs): exc_info = sys.exc_info() error_msg = 'exc_mailer() caught an exception, email will be sent.' logger.exception(error_msg) + reraise = False if print_to_stderr: print(error_msg + ' ' + str(e), file=sys.stderr) try: @@ -249,7 +244,9 @@ def wrapper(wrapped, instance, args, kwargs): except Exception: logger.exception('exc_mailer(): send_mail_func() threw an exception, ' 'logging it & then re-raising original exception') - six.reraise(exc_info[0], exc_info[1], exc_info[2]) + reraise = True + if reraise: + raise finally: # delete the traceback so we don't have garbage collection issues. # see warning at: http://docs.python.org/library/sys.html#sys.exc_info diff --git a/blazeutils/error_handling.py b/blazeutils/error_handling.py index 6190aac..dc175e5 100644 --- a/blazeutils/error_handling.py +++ b/blazeutils/error_handling.py @@ -1,35 +1,4 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - import re -import sys - -from blazeutils.helpers import tolist -from blazeutils.decorators import deprecate - - -def tb_depth_in(depths): - """ - looks at the current traceback to see if the depth of the traceback - matches any number in the depths list. If a match is found, returns - True, else False. - """ - depths = tolist(depths) - if traceback_depth() in depths: - return True - return False -traceback_depth_in = tb_depth_in # noqa: E305 - - -@deprecate('tb_depth_in(), traceback_depth() deprecated, its a bad idea') -def traceback_depth(tb=None): - if tb is None: - _, _, tb = sys.exc_info() - depth = 0 - while tb.tb_next is not None: - depth += 1 - tb = tb.tb_next - return depth def raise_unexpected_import_error(our_import, exc): diff --git a/blazeutils/filesystem.py b/blazeutils/filesystem.py index 6c5636b..d66ae11 100644 --- a/blazeutils/filesystem.py +++ b/blazeutils/filesystem.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - from os import path from blazeutils.strings import randchars diff --git a/blazeutils/functional.py b/blazeutils/functional.py index b010920..c13b9fb 100644 --- a/blazeutils/functional.py +++ b/blazeutils/functional.py @@ -1,12 +1,7 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - import functools import itertools import inspect -import six - from blazeutils import curry @@ -77,7 +72,7 @@ def first_where(pred, iterable, default=None): :param default: is the default value to use if the predicate matches none of the elements. """ - return next(six.moves.filter(pred, iterable), default) + return next(filter(pred, iterable), default) def identity(x): @@ -119,7 +114,7 @@ def unzip(iterable): left, right = unzip(two_columned_list) or ([], []) """ - return list(map(list, list(six.moves.zip(*iterable)))) + return list(map(list, list(zip(*iterable)))) def flatten(iterable): diff --git a/blazeutils/helpers.py b/blazeutils/helpers.py index 23be5b9..6db6e04 100644 --- a/blazeutils/helpers.py +++ b/blazeutils/helpers.py @@ -1,10 +1,6 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - import csv import difflib from pprint import PrettyPrinter -import six import time from blazeutils.datastructures import OrderedDict @@ -63,7 +59,7 @@ def pformat(stuff, indent=4): def is_iterable(possible_iterable): - if isinstance(possible_iterable, six.string_types): + if isinstance(possible_iterable, str): return False try: iter(possible_iterable) diff --git a/blazeutils/importing.py b/blazeutils/importing.py index a659e92..53dc637 100644 --- a/blazeutils/importing.py +++ b/blazeutils/importing.py @@ -3,8 +3,6 @@ import site from os import path -import six - def prependsitedir(projdir, *args): """ @@ -81,7 +79,7 @@ def find_path_package(thepath): pname = find_path_package_name(thepath) if not pname: return None - fromlist = b'' if six.PY2 else '' + fromlist = '' return __import__(pname, globals(), locals(), [fromlist]) diff --git a/blazeutils/numbers.py b/blazeutils/numbers.py index d166a44..66fd86c 100644 --- a/blazeutils/numbers.py +++ b/blazeutils/numbers.py @@ -1,11 +1,5 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - from decimal import Decimal -from six.moves import map -from six.moves import range - # from http://docs.python.org/library/decimal.html#recipes def moneyfmt(value, places=2, curr='', sep=',', dp='.', diff --git a/blazeutils/rst.py b/blazeutils/rst.py index 114238d..ff1177d 100644 --- a/blazeutils/rst.py +++ b/blazeutils/rst.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - try: import docutils from docutils.core import publish_programmatically, Publisher @@ -82,7 +79,7 @@ def docinfo2dict(doctree): pub = rst2pub(rst_string) print docinfo2dict(pub.document) """ - nodes = doctree.traverse(docutils.nodes.docinfo) + nodes = list(doctree.findall(docutils.nodes.docinfo)) md = {} if not nodes: return md @@ -138,7 +135,7 @@ def create_toc(doctree, depth=9223372036854775807, writer_name='html', # want to be able to give just the sub-sections startnode = None if exclude_first_section: - nodes = doctree.traverse(docutils.nodes.section) + nodes = list(doctree.findall(docutils.nodes.section)) if nodes: startnode = nodes[0] @@ -196,7 +193,7 @@ def prefix_refids(document, href_prefix): # page. In that case, an href_prefix can be sent in. The only downfall # to doing this way is that the writer automatically sets an "external" # class on a reference with 'refuri' instead of 'refid'. - nodes = document.traverse(docutils.nodes.reference) + nodes = document.findall(docutils.nodes.reference) for node in nodes: node['refuri'] = '{0}#{1}'.format(href_prefix, node['refid']) del node['refid'] diff --git a/blazeutils/sentinels.py b/blazeutils/sentinels.py index 79af36c..70fbb8e 100644 --- a/blazeutils/sentinels.py +++ b/blazeutils/sentinels.py @@ -1,6 +1,3 @@ -from __future__ import unicode_literals - - class NotGivenBase(object): """ an empty sentinel object that acts like None """ diff --git a/blazeutils/spreadsheets.py b/blazeutils/spreadsheets.py index be3459a..7c40213 100644 --- a/blazeutils/spreadsheets.py +++ b/blazeutils/spreadsheets.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - import datetime as dt from decimal import Decimal from io import BytesIO diff --git a/blazeutils/strings.py b/blazeutils/strings.py index d184efd..934f318 100644 --- a/blazeutils/strings.py +++ b/blazeutils/strings.py @@ -1,14 +1,8 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - import hashlib import random import re import time -import six -from six.moves import range - class StringIndenter(object): @@ -133,7 +127,7 @@ def randnumerics(n=12): def randhash(): - random_str = six.text_type(random.random()) + six.text_type(time.perf_counter()) + random_str = str(random.random()) + str(time.perf_counter()) return hashlib.md5(random_str.encode('utf-8')).hexdigest() diff --git a/blazeutils/testing.py b/blazeutils/testing.py index f539d5f..4b07fc2 100644 --- a/blazeutils/testing.py +++ b/blazeutils/testing.py @@ -1,10 +1,5 @@ -from __future__ import absolute_import -from __future__ import print_function -from __future__ import unicode_literals - import datetime as dt import difflib -import inspect from io import StringIO import logging import re @@ -14,8 +9,6 @@ from blazeutils.decorators import deprecate from blazeutils.log import clear_handlers_by_attr from blazeutils.helpers import Tee, prettifysql -import six -from six.moves import zip as izip import wrapt @@ -140,7 +133,7 @@ def decorate(fn, instance, args, kw): with warnings.catch_warnings(record=True) as wcm: retval = fn(*args, **kw) count = 0 - for w, m in izip(wcm, messages): + for w, m in zip(wcm, messages): count += 1 assert m is not None, 'No message to match warning: %s' % w.message assert w is not None, 'No warning to match message #%s: %s' % (count, m) @@ -152,85 +145,6 @@ def decorate(fn, instance, args, kw): return decorate -@deprecate('The @raises decorator is deprecated. Use pytest.raises instead.') -def raises(arg1, arg2=None, re_esc=True, **kwargs): # noqa - """ - Decorate a test encorcing it emits the given Exception and message - regex. - - Arguments to this decorator can be one or both of: - - A) Exception type or callable to validate the exception - B) If A is an Exception type, then a message or regex to match against the string - representation of the exception - - So, all the following are valid: - - @raises(AttributeError) - @raises("object has no attribute 'foo'") - @raises(AttributeError, "object has no attribute 'foo') - @raises("^.+object has no attribute 'foo'", AttributeError) - - # with regex support - @raises("^.+object has no attribute 'foo'", re_esc=False) - - # using custom exception validator - @raises(my_custom_validator) - - my_custom_validator() should accept a single argument, the exception caught by @raises, - and return True if the exception was expected and False otherwise - - @raises also supports examing arbitrary attributes on the exception for a given message - by using keyword arguments: - - @raises(SomeException, foo='bar') - - This will ensure that the exception is of the SomeException type also that the exception - has an attribute "foo" with a value of "bar." No regex support currently for these - messages. - """ - exc_validator = None - # if arg1 is callable, and not a class or, if it is a class, not a BaseException, assume - # arg1 should be a validator of the exception - if callable(arg1) and (not inspect.isclass(arg1) or not issubclass(arg1, BaseException)): - exc_validator = arg1 - msgregex = None - etype = None - elif isinstance(arg1, six.string_types): - msgregex = arg1 - etype = arg2 - elif isinstance(arg2, six.string_types): - etype = arg1 - msgregex = arg2 - else: - etype = arg1 - msgregex = None - - if re_esc and msgregex: - msgregex = re.escape(msgregex) - - @wrapt.decorator - def decorate(fn, instance, args, kw): - try: - fn(*args, **kw) - assert False, '@raises: no exception raised in %s()' % fn.__name__ - except Exception as e: - if exc_validator is not None and not exc_validator(e): - raise - if etype is not None and not isinstance(e, etype): - raise - if msgregex is not None and not re.search(msgregex, str(e)): - raise - for attrname, msg in six.iteritems(kwargs): - if not hasattr(e, attrname): - print('@raises: exception missing "{0}" attribute'.format(attrname)) - raise - if getattr(e, attrname) != msg: - raise - - return decorate - - def assert_equal_sql(sql, correct_sql): sql_split = prettifysql(sql) correct_sql_split = prettifysql(correct_sql) diff --git a/blazeutils/tests/test_config.py b/blazeutils/tests/test_config.py index a1b4722..42877be 100644 --- a/blazeutils/tests/test_config.py +++ b/blazeutils/tests/test_config.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals import copy from blazeutils.config import QuickSettings diff --git a/blazeutils/tests/test_containers.py b/blazeutils/tests/test_containers.py index 8a034cd..e64cdf1 100644 --- a/blazeutils/tests/test_containers.py +++ b/blazeutils/tests/test_containers.py @@ -1,7 +1,4 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - -import six.moves.cPickle as pickle +import pickle from blazeutils.containers import LazyDict, HTMLAttributes diff --git a/blazeutils/tests/test_datastructures.py b/blazeutils/tests/test_datastructures.py index 0b8a7c9..5c5781a 100644 --- a/blazeutils/tests/test_datastructures.py +++ b/blazeutils/tests/test_datastructures.py @@ -1,11 +1,7 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - +import pickle import random import pytest -from six.moves import range -import six.moves.cPickle as pickle from blazeutils.datastructures import DumbObject, OrderedProperties, OrderedDict, \ LazyOrderedDict, LazyDict, UniqueList diff --git a/blazeutils/tests/test_datetime.py b/blazeutils/tests/test_datetime.py index 9b6d85e..123e870 100644 --- a/blazeutils/tests/test_datetime.py +++ b/blazeutils/tests/test_datetime.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - import datetime as dt from blazeutils.dates import safe_strftime, ensure_datetime, ensure_date, trim_mils diff --git a/blazeutils/tests/test_decorators.py b/blazeutils/tests/test_decorators.py index 9b8c452..fa99b6f 100644 --- a/blazeutils/tests/test_decorators.py +++ b/blazeutils/tests/test_decorators.py @@ -1,11 +1,8 @@ -from __future__ import absolute_import -from __future__ import unicode_literals -import warnings - import logging +from unittest.mock import Mock, patch, call +import warnings import pytest -from mock import Mock, patch, call from blazeutils.decorators import curry, decorator from blazeutils.decorators import exc_emailer, retry, hybrid_method @@ -98,11 +95,11 @@ def myfunc(): if str(e) != 'myfunc': raise - assert(m_log.exception.call_args_list == [ + assert m_log.exception.call_args_list == [ call('exc_mailer() caught an exception, email will be sent.'), call('exc_mailer(): send_mail_func() threw an exception, logging it & ' 'then re-raising original exception'), - ]) + ] def test_catch_arg_usage(self): send_mail = Mock() diff --git a/blazeutils/tests/test_error_handling.py b/blazeutils/tests/test_error_handling.py index 8121927..df2fe40 100644 --- a/blazeutils/tests/test_error_handling.py +++ b/blazeutils/tests/test_error_handling.py @@ -1,37 +1,4 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - -import pytest - -from blazeutils.error_handling import tb_depth_in, traceback_depth, _uie_matches - - -def test_traceback_funcs(): - try: - import somethingthatwontbethereihope # noqa - assert False, 'expected import error' - except ImportError: - with pytest.warns(DeprecationWarning, match='.+its a bad idea'): - assert traceback_depth() == 0, 'if this test fails, you probably have something ' \ - 'wrapping __import__' - - try: - from ._bad_import import foobar # noqa - assert False, 'expected Import Error' - except ImportError: - with pytest.warns(DeprecationWarning, match='.+its a bad idea'): - assert traceback_depth() == 0 - - try: - from ._bad_import_deeper import foobar2 # noqa - assert False, 'expected import error' - except ImportError: - with pytest.warns(DeprecationWarning, match='.+its a bad idea'): - assert traceback_depth() == 1 - - assert tb_depth_in(1) - assert tb_depth_in((0, 1)) - assert not tb_depth_in((3, 4)) +from blazeutils.error_handling import _uie_matches class TestRaiseUIE(object): diff --git a/blazeutils/tests/test_filesystem.py b/blazeutils/tests/test_filesystem.py index a9e213c..f925dc3 100644 --- a/blazeutils/tests/test_filesystem.py +++ b/blazeutils/tests/test_filesystem.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - from os import path from tempfile import gettempdir from blazeutils.filesystem import randfile diff --git a/blazeutils/tests/test_functional.py b/blazeutils/tests/test_functional.py index b359d36..65526b9 100644 --- a/blazeutils/tests/test_functional.py +++ b/blazeutils/tests/test_functional.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from blazeutils.functional import posargs_limiter import blazeutils.functional as func diff --git a/blazeutils/tests/test_helpers.py b/blazeutils/tests/test_helpers.py index 6a6e008..2714dd5 100644 --- a/blazeutils/tests/test_helpers.py +++ b/blazeutils/tests/test_helpers.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - from blazeutils.helpers import multi_pop, is_iterable, grouper, is_empty, pformat, \ pprint, tolist, toset from blazeutils.helpers import unique, prettifysql, diff, ensure_tuple, \ diff --git a/blazeutils/tests/test_importing.py b/blazeutils/tests/test_importing.py index 958a690..03866a6 100644 --- a/blazeutils/tests/test_importing.py +++ b/blazeutils/tests/test_importing.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - from os import path from blazeutils.importing import find_path_package, import_split, import_string diff --git a/blazeutils/tests/test_numbers.py b/blazeutils/tests/test_numbers.py index 8cd387f..c0c551a 100644 --- a/blazeutils/tests/test_numbers.py +++ b/blazeutils/tests/test_numbers.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - from blazeutils.numbers import moneyfmt, decimalfmt, ensure_int, convert_int diff --git a/blazeutils/tests/test_rst.py b/blazeutils/tests/test_rst.py index d8d3433..1097317 100644 --- a/blazeutils/tests/test_rst.py +++ b/blazeutils/tests/test_rst.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - from importlib import reload import sys diff --git a/blazeutils/tests/test_sentinels.py b/blazeutils/tests/test_sentinels.py index b915867..6b92676 100644 --- a/blazeutils/tests/test_sentinels.py +++ b/blazeutils/tests/test_sentinels.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - from blazeutils.sentinels import NotGiven, NotGivenIter, is_notgiven from blazeutils.helpers import is_iterable diff --git a/blazeutils/tests/test_spreadsheets.py b/blazeutils/tests/test_spreadsheets.py index 4de0722..5cb68f3 100644 --- a/blazeutils/tests/test_spreadsheets.py +++ b/blazeutils/tests/test_spreadsheets.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, unicode_literals - import datetime as dt import decimal diff --git a/blazeutils/tests/test_sqlalchemy.py b/blazeutils/tests/test_sqlalchemy.py index 93ca60e..d9e0f10 100644 --- a/blazeutils/tests/test_sqlalchemy.py +++ b/blazeutils/tests/test_sqlalchemy.py @@ -1,8 +1,3 @@ -from __future__ import absolute_import -from __future__ import print_function -from __future__ import unicode_literals - -from six.moves import range from sqlalchemy import Column, Integer, String, create_engine, ForeignKey, event from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker, relationship diff --git a/blazeutils/tests/test_strings.py b/blazeutils/tests/test_strings.py index aafd28c..8bffd67 100644 --- a/blazeutils/tests/test_strings.py +++ b/blazeutils/tests/test_strings.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import unicode_literals - from blazeutils.strings import StringIndenter, simplify_string, case_cw2us, case_mc2us, \ case_us2mc, case_us2cw, reindent, randchars, randnumerics, randhash diff --git a/blazeutils/tests/test_testing.py b/blazeutils/tests/test_testing.py index 6c330da..a055ca2 100644 --- a/blazeutils/tests/test_testing.py +++ b/blazeutils/tests/test_testing.py @@ -1,12 +1,9 @@ -from __future__ import absolute_import -from __future__ import unicode_literals import datetime as dt -import sys +from unittest import mock -import mock import pytest -from blazeutils.testing import raises, assert_equal_sql, assert_equal_txt, \ +from blazeutils.testing import assert_equal_sql, assert_equal_txt, \ mock_date_today, mock_datetime_now, mock_datetime_utcnow @@ -26,106 +23,6 @@ def _is_attribute_exception(exc): return isinstance(exc, AttributeError) -class TestRaisesDecorator(object): - - @raises(AttributeError) - def test_arg1(self): - assert sys.foo - - @raises("object has no attribute 'foo'") - def test_arg2(self): - raise Exception("object has no attribute 'foo'") - - @raises(AttributeError, "object has no attribute 'foo'") - def test_arg3(self): - raise AttributeError("object has no attribute 'foo'") - - @raises("object has no attribute 'foo'", AttributeError) - def test_arg4(self): - raise AttributeError("object has no attribute 'foo'") - - @raises(_is_attribute_exception) - def test_callable_validator(self): - assert sys.foo - - def test_non_matching_message(self): - try: - @raises("foobar", AttributeError) - def wrapper(): - assert sys.foo - wrapper() - assert False, '@raises hid the exception but shouldn\'t have' - except AttributeError as e: - if "module object has no attribute foo" != str(e).replace("'", '') and \ - "module sys has no attribute foo" != str(e).replace("'", ''): - raise - - def test_non_matching_type(self): - try: - @raises(ValueError, "^.+object has no attribute 'foo'") - def wrapper(): - assert sys.foo - wrapper() - assert False, '@raises hid the exception but shouldn\'t have' - except AttributeError as e: - if "module object has no attribute foo" != str(e).replace("'", '') and \ - "module sys has no attribute foo" != str(e).replace("'", ''): - raise - - def test_callable_validator_returns_false(self): - try: - @raises(_is_attribute_exception) - def wrapper(): - raise ValueError('test ve') - wrapper() - assert False, '@raises hid the exception but shouldn\'t have' - except ValueError as e: - if "test ve" != str(e): - raise - - def test_no_exception_raised(self): - try: - @raises(ValueError, "^.+object has no attribute 'foo'") - def wrapper(): - pass - wrapper() - assert False, '@raises should have complained that an exception was not raised' - except AssertionError as e: - if "@raises: no exception raised in wrapper()" != str(e): - raise - - @raises('[with brackets]') - def test_non_regex(self): - raise Exception('[with brackets]') - - @raises(LikeWerkzeugExc, description='Foobar') - def test_custom_attributes_ok(self): - raise LikeWerkzeugExc('Foobar') - - def test_custom_attributes_missing(self): - try: - @raises(LikeWerkzeugExc, description='Foobar') - def wrapper(): - raise Exception('baz') - wrapper() - assert False, '@raises should have complained that the exception was ' \ - 'missing the description attribute' - except Exception as e: - if "baz" != str(e): - raise - - def test_custom_attributes_fails(self): - try: - @raises(LikeWerkzeugExc, description='Foobar') - def wrapper(): - raise LikeWerkzeugExc('baz') - wrapper() - assert False, '@raises should have complained that the description ' \ - 'attribute did not match' - except LikeWerkzeugExc: - pass - - def test_assert_equal_sql(): s2 = s1 = """ select foo, diff --git a/setup.py b/setup.py index 300a320..b0ab758 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,6 @@ test_requires = [ 'codecov', 'docutils', - 'mock', 'openpyxl', 'pytest', 'pytest-cov', @@ -55,16 +54,17 @@ 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', ], python_requires='>=3', license='BSD', packages=['blazeutils'], zip_safe=False, include_package_data=True, - install_requires=['six', 'wrapt'], + install_requires=['wrapt'], extras_require={ 'dev': dev_requires, 'test': test_requires, diff --git a/stable-requirements.txt b/stable-requirements.txt new file mode 100644 index 0000000..ee5d0f3 --- /dev/null +++ b/stable-requirements.txt @@ -0,0 +1,33 @@ +attrs==22.1.0 +certifi==2022.9.24 +charset-normalizer==2.1.1 +codecov==2.1.12 +colorama==0.4.6 +coverage==6.5.0 +distlib==0.3.6 +docutils==0.19 +et-xmlfile==1.1.0 +exceptiongroup==1.0.0rc9 +filelock==3.8.0 +greenlet==1.1.3.post0 +idna==3.4 +iniconfig==1.1.1 +openpyxl==3.0.10 +packaging==21.3 +platformdirs==2.5.2 +pluggy==1.0.0 +py==1.11.0 +pyparsing==3.0.9 +pytest==7.2.0 +pytest-cov==4.0.0 +requests==2.28.1 +six==1.16.0 +SQLAlchemy==1.4.42 +tomli==2.0.1 +tox==3.27.0 +urllib3==1.26.12 +virtualenv==20.16.6 +wrapt==1.14.1 +xlrd==1.2.0 +XlsxWriter==3.0.3 +xlwt==1.3.0 diff --git a/tox.ini b/tox.ini index 6a45175..6a678c4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,24 +1,33 @@ [tox] -envlist = py36,py37,py38,flake8 +envlist = py37,py{38,39,310}-{base,stable},project [testenv] commands = + stable: pip install --progress-bar off -r ./stable-requirements.txt pip install --progress-bar off .[test] py.test \ + -c .circleci/pytest.ini \ --tb native \ - --strict \ + --strict-markers \ --cov-config .coveragerc \ --cov blazeutils \ --cov-report xml \ --no-cov-on-fail \ --junit-xml={toxinidir}/.ci/test-reports/{envname}.pytests.xml \ - blazeutils + blazeutils {posargs} -[testenv:flake8] +[testenv:project] +basepython = python3.9 skip_install = true usedevelop = false -deps = flake8 -commands = flake8 --max-complexity=11 blazeutils +deps = + flake8 + twine +commands = + # check-manifest --ignore tox.ini,tests* + python setup.py sdist + twine check dist/* + flake8 --max-complexity=11 blazeutils [flake8] max-line-length = 100 diff --git a/wheelhouse.ini b/wheelhouse.ini deleted file mode 100644 index 6145057..0000000 --- a/wheelhouse.ini +++ /dev/null @@ -1,6 +0,0 @@ -[wheelhouse] -requirement_files = - development.txt - -# Make sure each package has a wheel built for python 2 & 3. -pip_bins = pip, pip3.4