Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

expects

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expects - npm Package Compare versions

Comparing version
0.8.0rc1
to
0.8.0rc2
+1
-1
docs/conf.py

@@ -62,3 +62,3 @@ # -*- coding: utf-8 -*-

# The full version, including alpha/beta/rc tags.
release = '0.8.0rc1'
release = '0.8.0rc2'

@@ -65,0 +65,0 @@ # The language for content autogenerated by Sphinx. Refer to documentation

Metadata-Version: 1.1
Name: expects
Version: 0.8.0rc1
Version: 0.8.0rc2
Summary: Expressive and extensible TDD/BDD assertion library for Python

@@ -5,0 +5,0 @@ Home-page: https://github.com/jaimegildesagredo/expects

@@ -13,20 +13,1 @@ # -*- coding: utf-8 -*

string_types = (bytes, str)
def with_metaclass(meta, *bases):
"""Extracted from:
http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/#metaclass-syntax-changes
"""
class metaclass(meta):
__call__ = type.__call__
__init__ = type.__init__
def __new__(cls, name, this_bases, d):
if this_bases is None:
return type.__new__(cls, name, (), d)
return meta(name, bases, d)
return metaclass('temporary_class', None, {})

@@ -118,3 +118,3 @@ # -*- coding: utf-8 -*

if reasons:
message += '\n but: {}'.format('\n '.join(reasons))
message += '\n but: {0}'.format('\n '.join(reasons))

@@ -145,3 +145,3 @@ return message

if reasons:
message += '\n but: {}'.format('\n '.join(reasons))
message += '\n but: {0}'.format('\n '.join(reasons))

@@ -198,4 +198,4 @@ return message

def __repr__(self):
return '{} and {}'.format(repr(self.op1).replace(' and ', ', '),
repr(self.op2))
return '{0} and {1}'.format(repr(self.op1).replace(' and ', ', '),
repr(self.op2))

@@ -215,5 +215,5 @@

def __repr__(self):
return '{} or {}'.format(repr(self.op1).replace(' or ', ', '),
repr(self.op2))
return '{0} or {1}'.format(repr(self.op1).replace(' or ', ', '),
repr(self.op2))
from .built_in import equal as equal_matcher

@@ -52,4 +52,4 @@ # -*- coding: utf-8 -*

if expected in subject:
return True, 'item {!r} found'.format(expected)
return False, 'item {!r} not found'.format(expected)
return True, 'item {0!r} found'.format(expected)
return False, 'item {0!r} not found'.format(expected)

@@ -60,5 +60,5 @@ expected = default_matcher(expected)

if matches:
return True, 'item {!r} found'.format(expected)
return True, 'item {0!r} found'.format(expected)
return False, 'item {!r} not found'.format(expected)
return False, 'item {0!r} not found'.format(expected)

@@ -75,4 +75,4 @@ @_normalize_sequence

def __repr__(self):
return '{} {expected}'.format(type(self).__name__.replace('_', ' '),
expected=plain_enumerate(self._expected))
return '{0} {1}'.format(type(self).__name__.replace('_', ' '),
plain_enumerate(self._expected))

@@ -90,5 +90,5 @@

if not result:
return False, ['item {!r} not found at index {}'.format(expected_item, index)]
return False, ['item {0!r} not found at index {1}'.format(expected_item, index)]
except IndexError:
return False, ['item {!r} not found at index {}'.format(expected_item, index)]
return False, ['item {0!r} not found at index {1}'.format(expected_item, index)]

@@ -101,3 +101,3 @@ return len(subject) == len(self._expected), ['have a different length']

if part != subject[currentIndex:currentIndex+len(part)]:
return False, ['item equal {!r} not found at index {}'.format(part, currentIndex)]
return False, ['item equal {0!r} not found at index {1}'.format(part, currentIndex)]
currentIndex = len(part)

@@ -113,3 +113,3 @@

if not item in subject:
return False, ['item {!r} not found'.format(item)]
return False, ['item {0!r} not found'.format(item)]
return len(subject) == len(''.join(self._expected)), ['have a different length']

@@ -116,0 +116,0 @@

@@ -46,11 +46,11 @@ # -*- coding: utf-8 -*

except KeyError:
return False, 'key {!r} {!r} not found'.format(name, expected_value)
return False, 'key {0!r} {1!r} not found'.format(name, expected_value)
else:
result, _ = expected_value._match(value)
reason_message = 'not found' if not result else 'found'
return result, 'key {!r} {!r} {}'.format(name, expected_value, reason_message)
return result, 'key {0!r} {1!r} {2}'.format(name, expected_value, reason_message)
if name in subject:
return True, 'key {!r} found'.format(name)
return False, 'key {!r} not found'.format(name)
return True, 'key {0!r} found'.format(name)
return False, 'key {0!r} not found'.format(name)

@@ -65,3 +65,3 @@ def _match_negated(self, subject):

def __repr__(self):
return '{} {}'.format(type(self).__name__.replace('_', ' '),
return '{0} {1}'.format(type(self).__name__.replace('_', ' '),
plain_enumerate(*self._expected))

@@ -68,0 +68,0 @@

@@ -14,3 +14,3 @@ # -*- coding: utf-8 -*

result, _ = expected_length._match(actual_length)
return result, ['was {!r}'.format(actual_length)]
return result, ['was {0!r}'.format(actual_length)]

@@ -17,0 +17,0 @@ def __length(self, collection):

# -*- coding: utf-8 -*
from .. import Matcher, default_matcher
from ... import _compat
from ...texts import plain_enumerate

@@ -34,3 +33,3 @@

except AttributeError:
return False, 'property {!r} not found'.format(name)
return False, 'property {0!r} not found'.format(name)
else:

@@ -40,12 +39,12 @@ expected_value = default_matcher(args[0])

if not result:
return False, 'property {!r} {!r} not found'.format(name, expected_value)
return True, 'property {!r} {!r} found'.format(name, expected_value)
return False, 'property {0!r} {1!r} not found'.format(name, expected_value)
return True, 'property {0!r} {1!r} found'.format(name, expected_value)
if not hasattr(subject, name):
return False, 'property {!r} not found'.format(name)
return True, 'property {!r} found'.format(name)
return False, 'property {0!r} not found'.format(name)
return True, 'property {0!r} found'.format(name)
def __repr__(self):
return '{} {}'.format(type(self).__name__.replace('_', ' '),
plain_enumerate(*self._expected))
return '{0} {1}'.format(type(self).__name__.replace('_', ' '),
plain_enumerate(*self._expected))

@@ -52,0 +51,0 @@

@@ -15,2 +15,2 @@ # -*- coding: utf-8 -*

def __repr__(self):
return 'not {!r}'.format(self._matcher)
return 'not {0!r}'.format(self._matcher)

@@ -22,8 +22,8 @@ # -*- coding: utf-8 -*

result, _ = expected_value._match(actual_value)
return result, ['{} raised with {!r}'.format(type(exc).__name__, actual_value)]
return result, ['{0} raised with {1!r}'.format(type(exc).__name__, actual_value)]
return True, ['{} raised'.format(type(exc).__name__)]
return True, ['{0} raised'.format(type(exc).__name__)]
except Exception as err:
return False, ['{} raised'.format(type(err).__name__)]
return False, ['{0} raised'.format(type(err).__name__)]
else:

@@ -30,0 +30,0 @@ return False, ['no exception raised']

@@ -15,3 +15,3 @@ # -*- coding: utf-8 -*

def _match(self, subject):
if self._is_unordered(subject):
if self._is_unordered_dict(subject):
return False, ['does not have ordered keys']

@@ -21,8 +21,13 @@

def _is_unordered(self, subject):
return (isinstance(subject, collections.Mapping) and
not isinstance(subject, collections.OrderedDict))
def _is_unordered_dict(self, subject):
if isinstance(subject, collections.Mapping):
if not hasattr(collections, 'OrderedDict'):
return True
return not isinstance(subject, collections.OrderedDict)
return False
def _match_negated(self, subject):
if self._is_unordered(subject):
if self._is_unordered_dict(subject):
return False, ['does not have ordered keys']

@@ -34,4 +39,4 @@

def __repr__(self):
return '{} {expected}'.format(type(self).__name__.replace('_', ' '),
expected=plain_enumerate(self._args))
return '{0} {1}'.format(type(self).__name__.replace('_', ' '),
plain_enumerate(self._args))

@@ -44,3 +49,3 @@

subject.startswith(self._args[0]),
['starts with {!r}'.format(subject[:-len(self._args[0])])])
['starts with {0!r}'.format(subject[:-len(self._args[0])])])

@@ -50,3 +55,3 @@ actual_start = list(subject)[:len(self._args)]

list(self._args) == actual_start,
['starts with {!r}'.format(actual_start)])
['starts with {0!r}'.format(actual_start)])

@@ -59,3 +64,3 @@

subject.endswith(self._args[0]),
['ends with {!r}'.format(subject[-len(self._args[0]):])])
['ends with {0!r}'.format(subject[-len(self._args[0]):])])

@@ -65,2 +70,2 @@ actual_end = list(subject)[-len(self._args):]

list(self._args) == actual_end,
['ends with {!r}'.format(actual_end)])
['ends with {0!r}'.format(actual_end)])

@@ -11,16 +11,6 @@ # -*- coding: utf-8 -*-

from ._compat import with_metaclass
from .matchers.built_in import end_with as end_with_matcher
class _ContextManagerMeta(type):
def __enter__(cls):
pass
def __exit__(cls, exc_type, exc_value, exc_tb):
cls._handle_exception(exc_type, exc_value, exc_tb)
return True
class failure(with_metaclass(_ContextManagerMeta)):
class _Failure(object):
"""The :class:`failure` context manager can be used to build

@@ -75,4 +65,4 @@ assertions of your expectation failures. It tests that the

def __init__(self, message):
if not hasattr(message, '_match'):
def __init__(self, message=None):
if message is not None and not hasattr(message, '_match'):
message = end_with_matcher(message)

@@ -82,2 +72,6 @@

def __call__(self, message):
return _Failure(message)
def __enter__(self):

@@ -89,9 +83,10 @@ pass

exc_message = str(exc_value)
if self._message is not None:
exc_message = str(exc_value)
matches, _ = self._message._match(exc_message)
if not matches:
raise AssertionError(
"Expected error message {!r} {!r}".format(
exc_message, self._message))
matches, _ = self._message._match(exc_message)
if not matches:
raise AssertionError(
"Expected error message {0!r} {1!r}".format(
exc_message, self._message))

@@ -107,5 +102,5 @@ return True

raise AssertionError(
'Expected AssertionError to be raised but {} raised.'
'\n\n{}'.format(exc_type.__name__,
_format_exception(exc_type, exc_value, exc_tb))
'Expected AssertionError to be raised but {0} raised.'
'\n\n{1}'.format(exc_type.__name__,
_format_exception(exc_type, exc_value, exc_tb))
)

@@ -116,1 +111,4 @@

return ''.join(traceback.format_exception(exc_type, exc_value, exc_tb))
failure = _Failure()

@@ -16,3 +16,3 @@ # -*- coding: utf-8 -*

for k, v in _sorted_items(kwargs):
tokens.append('{!r} {!r}'.format(k, default_matcher(v)))
tokens.append('{0!r} {1!r}'.format(k, default_matcher(v)))

@@ -19,0 +19,0 @@ total = len(args) + len(kwargs)

Metadata-Version: 1.1
Name: expects
Version: 0.8.0rc1
Version: 0.8.0rc2
Summary: Expressive and extensible TDD/BDD assertion library for Python

@@ -5,0 +5,0 @@ Home-page: https://github.com/jaimegildesagredo/expects

[egg_info]
tag_date = 0
tag_svn_revision = 0
tag_build =
tag_svn_revision = 0

@@ -9,3 +9,3 @@ # -*- coding: utf-8 -*-

name='expects',
version='0.8.0rc1',
version='0.8.0rc2',
description='Expressive and extensible TDD/BDD assertion library for Python',

@@ -12,0 +12,0 @@ long_description=long_description,

# -*- coding: utf-8 -*
from collections import OrderedDict
try:
from collections import OrderedDict
except ImportError:
OrderedDict = lambda *args: None

@@ -28,2 +31,5 @@ from expects import *

with it('should pass if ordered dict ends with keys'):
if self.ordered_dct is None:
return
expected_args = list(self.ordered_dct)[:2]

@@ -36,7 +42,7 @@

with failure('but: ends with {!r}'.format(str_[-5:])):
with failure('but: ends with {0!r}'.format(str_[-5:])):
expect(self.str).to(end_with(str_[:5]))
with it('should fail if list ends with first arg but not second'):
with failure('but: ends with {!r}'.format(self.lst[-2:])):
with failure('but: ends with {0!r}'.format(self.lst[-2:])):
expect(self.lst).to(end_with(self.lst[-1], self.lst[-1]))

@@ -43,0 +49,0 @@

# -*- coding: utf-8 -*
from collections import OrderedDict
try:
from collections import OrderedDict
except ImportError:
OrderedDict = lambda *args: None

@@ -28,2 +31,5 @@ from expects import *

with it('passes if ordered dict starts with keys'):
if self.ordered_dct is None:
return
expected_args = list(self.ordered_dct)[:2]

@@ -37,15 +43,15 @@

with it('fails if string does not start with string'):
with failure('but: starts with {!r}'.format(self.str[:-5])):
with failure('but: starts with {0!r}'.format(self.str[:-5])):
expect(self.str).to(start_with(self.str[-5:]))
with it('fails if list does not start with arg'):
with failure('but: starts with {!r}'.format(self.lst[:1])):
with failure('but: starts with {0!r}'.format(self.lst[:1])):
expect(self.lst).to(start_with(self.lst[1]))
with it('fails if list does not start with args'):
with failure('but: starts with {!r}'.format(self.lst[:2])):
with failure('but: starts with {0!r}'.format(self.lst[:2])):
expect(self.lst).to(start_with(*self.lst[1:]))
with it('fails if list starts with first arg but not second'):
with failure('but: starts with {!r}'.format(self.lst[:2])):
with failure('but: starts with {0!r}'.format(self.lst[:2])):
expect(self.lst).to(start_with(self.lst[0], self.lst[0]))

@@ -52,0 +58,0 @@

@@ -34,7 +34,7 @@ # -*- coding: utf-8 -*-

with failure(self.message):
raise AssertionError("Expected 'foo' {}".format(self.message))
raise AssertionError("Expected 'foo' {0}".format(self.message))
with it('passes if assertion error raised and message matches'):
with failure(match(self.pattern)):
raise AssertionError("Expected 'foo' {}".format(self.message))
raise AssertionError("Expected 'foo' {0}".format(self.message))

@@ -41,0 +41,0 @@ with it('passes if assertion error raised and message has length 0'):