body_hash
stringlengths 64
64
| body
stringlengths 23
109k
| docstring
stringlengths 1
57k
| path
stringlengths 4
198
| name
stringlengths 1
115
| repository_name
stringlengths 7
111
| repository_stars
float64 0
191k
| lang
stringclasses 1
value | body_without_docstring
stringlengths 14
108k
| unified
stringlengths 45
133k
|
|---|---|---|---|---|---|---|---|---|---|
2469be388d264ce89c6011df5538c313f481d9fd2a7b766348c73e18fca11910
|
def test_class_dependency():
'Inject class.\n\n Instantiate class from the same scope and inject its instance.\n '
class Foo(object):
def __init__(self, add, bar):
self.add = add
self.bar = bar
def do(self, x):
return self.add(self.bar.go(x), self.bar.go(x))
class Bar(object):
def __init__(self, mul):
self.mul = mul
def go(self, x):
return self.mul(x, x)
class Summator(Injector):
foo = Foo
bar = Bar
add = (lambda x, y: (x + y))
mul = (lambda x, y: (x * y))
assert (Summator.foo.do(2) == 8)
|
Inject class.
Instantiate class from the same scope and inject its instance.
|
tests/test_injector.py
|
test_class_dependency
|
hyperleex/dependencies
| 0
|
python
|
def test_class_dependency():
'Inject class.\n\n Instantiate class from the same scope and inject its instance.\n '
class Foo(object):
def __init__(self, add, bar):
self.add = add
self.bar = bar
def do(self, x):
return self.add(self.bar.go(x), self.bar.go(x))
class Bar(object):
def __init__(self, mul):
self.mul = mul
def go(self, x):
return self.mul(x, x)
class Summator(Injector):
foo = Foo
bar = Bar
add = (lambda x, y: (x + y))
mul = (lambda x, y: (x * y))
assert (Summator.foo.do(2) == 8)
|
def test_class_dependency():
'Inject class.\n\n Instantiate class from the same scope and inject its instance.\n '
class Foo(object):
def __init__(self, add, bar):
self.add = add
self.bar = bar
def do(self, x):
return self.add(self.bar.go(x), self.bar.go(x))
class Bar(object):
def __init__(self, mul):
self.mul = mul
def go(self, x):
return self.mul(x, x)
class Summator(Injector):
foo = Foo
bar = Bar
add = (lambda x, y: (x + y))
mul = (lambda x, y: (x * y))
assert (Summator.foo.do(2) == 8)<|docstring|>Inject class.
Instantiate class from the same scope and inject its instance.<|endoftext|>
|
17b89ef503545563555bbb15dde748e198988c1999c91aae87e8411a87f93fca
|
def test_do_not_instantiate_dependencies_ended_with_class():
'Do not call class constructor, if it stored with name ended `_class`.\n\n For example, `logger_class`.\n '
class Foo(object):
pass
class Bar(Injector):
foo_class = Foo
assert isclass(Bar.foo_class)
|
Do not call class constructor, if it stored with name ended `_class`.
For example, `logger_class`.
|
tests/test_injector.py
|
test_do_not_instantiate_dependencies_ended_with_class
|
hyperleex/dependencies
| 0
|
python
|
def test_do_not_instantiate_dependencies_ended_with_class():
'Do not call class constructor, if it stored with name ended `_class`.\n\n For example, `logger_class`.\n '
class Foo(object):
pass
class Bar(Injector):
foo_class = Foo
assert isclass(Bar.foo_class)
|
def test_do_not_instantiate_dependencies_ended_with_class():
'Do not call class constructor, if it stored with name ended `_class`.\n\n For example, `logger_class`.\n '
class Foo(object):
pass
class Bar(Injector):
foo_class = Foo
assert isclass(Bar.foo_class)<|docstring|>Do not call class constructor, if it stored with name ended `_class`.
For example, `logger_class`.<|endoftext|>
|
62ca5821c80e4b84d273b8cdf35751bae88d33a9e9199a02a583e6d4cd81fecc
|
def test_redefine_dependency():
'We can redefine dependency by inheritance from the `Injector`\n subclass.'
class Foo(object):
def __init__(self, add):
self.add = add
def do(self, x):
return self.add(x, x)
class Summator(Injector):
foo = Foo
add = (lambda x, y: (x + y))
class WrongSummator(Summator):
add = (lambda x, y: (x - y))
assert (WrongSummator.foo.do(1) == 0)
|
We can redefine dependency by inheritance from the `Injector`
subclass.
|
tests/test_injector.py
|
test_redefine_dependency
|
hyperleex/dependencies
| 0
|
python
|
def test_redefine_dependency():
'We can redefine dependency by inheritance from the `Injector`\n subclass.'
class Foo(object):
def __init__(self, add):
self.add = add
def do(self, x):
return self.add(x, x)
class Summator(Injector):
foo = Foo
add = (lambda x, y: (x + y))
class WrongSummator(Summator):
add = (lambda x, y: (x - y))
assert (WrongSummator.foo.do(1) == 0)
|
def test_redefine_dependency():
'We can redefine dependency by inheritance from the `Injector`\n subclass.'
class Foo(object):
def __init__(self, add):
self.add = add
def do(self, x):
return self.add(x, x)
class Summator(Injector):
foo = Foo
add = (lambda x, y: (x + y))
class WrongSummator(Summator):
add = (lambda x, y: (x - y))
assert (WrongSummator.foo.do(1) == 0)<|docstring|>We can redefine dependency by inheritance from the `Injector`
subclass.<|endoftext|>
|
009f5383c2990a5c1dfb2b9b58999cd0c74472f58ad6951c7dfcafb4b3d6425d
|
def test_override_keyword_argument_if_dependency_was_specified():
'Use specified dependency for constructor keyword arguments if dependency\n with desired name was mentioned in the injector.'
class Foo(object):
def __init__(self, add, y=1):
self.add = add
self.y = y
def do(self, x):
return self.add(x, self.y)
class Summator(Injector):
foo = Foo
add = (lambda x, y: (x + y))
y = 2
assert (Summator.foo.do(1) == 3)
|
Use specified dependency for constructor keyword arguments if dependency
with desired name was mentioned in the injector.
|
tests/test_injector.py
|
test_override_keyword_argument_if_dependency_was_specified
|
hyperleex/dependencies
| 0
|
python
|
def test_override_keyword_argument_if_dependency_was_specified():
'Use specified dependency for constructor keyword arguments if dependency\n with desired name was mentioned in the injector.'
class Foo(object):
def __init__(self, add, y=1):
self.add = add
self.y = y
def do(self, x):
return self.add(x, self.y)
class Summator(Injector):
foo = Foo
add = (lambda x, y: (x + y))
y = 2
assert (Summator.foo.do(1) == 3)
|
def test_override_keyword_argument_if_dependency_was_specified():
'Use specified dependency for constructor keyword arguments if dependency\n with desired name was mentioned in the injector.'
class Foo(object):
def __init__(self, add, y=1):
self.add = add
self.y = y
def do(self, x):
return self.add(x, self.y)
class Summator(Injector):
foo = Foo
add = (lambda x, y: (x + y))
y = 2
assert (Summator.foo.do(1) == 3)<|docstring|>Use specified dependency for constructor keyword arguments if dependency
with desired name was mentioned in the injector.<|endoftext|>
|
d161e6bd8994f13e5cabf65b40b2937c8389cf696c191c6e515d092effb39112
|
def test_preserve_keyword_argument_if_dependency_was_missed():
'Use constructor keyword arguments if dependency with desired name was\n missed in the injector.'
class Foo(object):
def __init__(self, add, y=1):
self.add = add
self.y = y
def do(self, x):
return self.add(x, self.y)
class Summator(Injector):
foo = Foo
add = (lambda x, y: (x + y))
assert (Summator.foo.do(1) == 2)
|
Use constructor keyword arguments if dependency with desired name was
missed in the injector.
|
tests/test_injector.py
|
test_preserve_keyword_argument_if_dependency_was_missed
|
hyperleex/dependencies
| 0
|
python
|
def test_preserve_keyword_argument_if_dependency_was_missed():
'Use constructor keyword arguments if dependency with desired name was\n missed in the injector.'
class Foo(object):
def __init__(self, add, y=1):
self.add = add
self.y = y
def do(self, x):
return self.add(x, self.y)
class Summator(Injector):
foo = Foo
add = (lambda x, y: (x + y))
assert (Summator.foo.do(1) == 2)
|
def test_preserve_keyword_argument_if_dependency_was_missed():
'Use constructor keyword arguments if dependency with desired name was\n missed in the injector.'
class Foo(object):
def __init__(self, add, y=1):
self.add = add
self.y = y
def do(self, x):
return self.add(x, self.y)
class Summator(Injector):
foo = Foo
add = (lambda x, y: (x + y))
assert (Summator.foo.do(1) == 2)<|docstring|>Use constructor keyword arguments if dependency with desired name was
missed in the injector.<|endoftext|>
|
e55e7eff88eda9fe3ce006185943eed0752fd5cd2bdf8272a87e9338e17d0849
|
def test_preserve_missed_keyword_argument_in_the_middle():
'Use default keyword argument and override following keyword argument\n since it was specified in the constructor.'
class Foo(object):
def __init__(self, x, y=1, z=2):
self.x = x
self.y = y
self.z = z
def do(self):
return ((self.x + self.y) + self.z)
class Container(Injector):
foo = Foo
x = 5
z = 1
assert (Container.foo.do() == 7)
|
Use default keyword argument and override following keyword argument
since it was specified in the constructor.
|
tests/test_injector.py
|
test_preserve_missed_keyword_argument_in_the_middle
|
hyperleex/dependencies
| 0
|
python
|
def test_preserve_missed_keyword_argument_in_the_middle():
'Use default keyword argument and override following keyword argument\n since it was specified in the constructor.'
class Foo(object):
def __init__(self, x, y=1, z=2):
self.x = x
self.y = y
self.z = z
def do(self):
return ((self.x + self.y) + self.z)
class Container(Injector):
foo = Foo
x = 5
z = 1
assert (Container.foo.do() == 7)
|
def test_preserve_missed_keyword_argument_in_the_middle():
'Use default keyword argument and override following keyword argument\n since it was specified in the constructor.'
class Foo(object):
def __init__(self, x, y=1, z=2):
self.x = x
self.y = y
self.z = z
def do(self):
return ((self.x + self.y) + self.z)
class Container(Injector):
foo = Foo
x = 5
z = 1
assert (Container.foo.do() == 7)<|docstring|>Use default keyword argument and override following keyword argument
since it was specified in the constructor.<|endoftext|>
|
bdfc91054eb3f25a48f541324cea5793f54a5abdef91ecc293001072207f4157
|
def test_class_named_argument_default_value():
'Allow classes as default argument values if argument name ends with\n `_class`.'
class Foo(object):
pass
class Bar(object):
def __init__(self, foo_class=Foo):
self.foo_class = foo_class
class Container(Injector):
bar = Bar
assert (Container.bar.foo_class is Foo)
|
Allow classes as default argument values if argument name ends with
`_class`.
|
tests/test_injector.py
|
test_class_named_argument_default_value
|
hyperleex/dependencies
| 0
|
python
|
def test_class_named_argument_default_value():
'Allow classes as default argument values if argument name ends with\n `_class`.'
class Foo(object):
pass
class Bar(object):
def __init__(self, foo_class=Foo):
self.foo_class = foo_class
class Container(Injector):
bar = Bar
assert (Container.bar.foo_class is Foo)
|
def test_class_named_argument_default_value():
'Allow classes as default argument values if argument name ends with\n `_class`.'
class Foo(object):
pass
class Bar(object):
def __init__(self, foo_class=Foo):
self.foo_class = foo_class
class Container(Injector):
bar = Bar
assert (Container.bar.foo_class is Foo)<|docstring|>Allow classes as default argument values if argument name ends with
`_class`.<|endoftext|>
|
9191fa6eb8a4cc6f6c200878668f0cec530d0da2036bd98aaba29f85cbf5d0a5
|
def test_injectable_without_its_own_init():
"Inject dependencies into object subclass which doesn't specify its own\n `__init__`."
class Foo(object):
def do(self):
return 1
class Baz(Injector):
foo = Foo
assert (Baz.foo.do() == 1)
|
Inject dependencies into object subclass which doesn't specify its own
`__init__`.
|
tests/test_injector.py
|
test_injectable_without_its_own_init
|
hyperleex/dependencies
| 0
|
python
|
def test_injectable_without_its_own_init():
"Inject dependencies into object subclass which doesn't specify its own\n `__init__`."
class Foo(object):
def do(self):
return 1
class Baz(Injector):
foo = Foo
assert (Baz.foo.do() == 1)
|
def test_injectable_without_its_own_init():
"Inject dependencies into object subclass which doesn't specify its own\n `__init__`."
class Foo(object):
def do(self):
return 1
class Baz(Injector):
foo = Foo
assert (Baz.foo.do() == 1)<|docstring|>Inject dependencies into object subclass which doesn't specify its own
`__init__`.<|endoftext|>
|
416904e993c369b96cd8b5e0884723182a429ecfb34ec75708dbfe2c6ac67a68
|
def test_injectable_with_parent_init():
'Inject dependencies into object which parent class define `__init__`.'
class Foo(object):
def __init__(self, x, y):
self.x = x
self.y = y
class Bar(Foo):
def add(self):
return (self.x + self.y)
class Baz(Injector):
bar = Bar
x = 1
y = 2
assert (Baz.bar.add() == 3)
|
Inject dependencies into object which parent class define `__init__`.
|
tests/test_injector.py
|
test_injectable_with_parent_init
|
hyperleex/dependencies
| 0
|
python
|
def test_injectable_with_parent_init():
class Foo(object):
def __init__(self, x, y):
self.x = x
self.y = y
class Bar(Foo):
def add(self):
return (self.x + self.y)
class Baz(Injector):
bar = Bar
x = 1
y = 2
assert (Baz.bar.add() == 3)
|
def test_injectable_with_parent_init():
class Foo(object):
def __init__(self, x, y):
self.x = x
self.y = y
class Bar(Foo):
def add(self):
return (self.x + self.y)
class Baz(Injector):
bar = Bar
x = 1
y = 2
assert (Baz.bar.add() == 3)<|docstring|>Inject dependencies into object which parent class define `__init__`.<|endoftext|>
|
195078ff5565da15165ca2c9668da808ebabf6c7124e80cf4ef924c0caeeb876
|
def test_injectable_with_parent_without_init():
"Inject dependencies into object which parent doesn't define\n `__init__`."
class Foo(object):
pass
class Bar(Foo):
def add(self):
return 3
class Baz(Injector):
bar = Bar
assert (Baz.bar.add() == 3)
|
Inject dependencies into object which parent doesn't define
`__init__`.
|
tests/test_injector.py
|
test_injectable_with_parent_without_init
|
hyperleex/dependencies
| 0
|
python
|
def test_injectable_with_parent_without_init():
"Inject dependencies into object which parent doesn't define\n `__init__`."
class Foo(object):
pass
class Bar(Foo):
def add(self):
return 3
class Baz(Injector):
bar = Bar
assert (Baz.bar.add() == 3)
|
def test_injectable_with_parent_without_init():
"Inject dependencies into object which parent doesn't define\n `__init__`."
class Foo(object):
pass
class Bar(Foo):
def add(self):
return 3
class Baz(Injector):
bar = Bar
assert (Baz.bar.add() == 3)<|docstring|>Inject dependencies into object which parent doesn't define
`__init__`.<|endoftext|>
|
4ae9020418c7a93db4ed77468ceb3cd5e8ae4eec4dda6f5b400a53f5a321f505
|
def test_let_factory():
'`Injector` subclass can produce its own subclasses with `let`\n factory.'
class Foo(Injector):
pass
assert issubclass(Foo.let(), Foo)
|
`Injector` subclass can produce its own subclasses with `let`
factory.
|
tests/test_injector.py
|
test_let_factory
|
hyperleex/dependencies
| 0
|
python
|
def test_let_factory():
'`Injector` subclass can produce its own subclasses with `let`\n factory.'
class Foo(Injector):
pass
assert issubclass(Foo.let(), Foo)
|
def test_let_factory():
'`Injector` subclass can produce its own subclasses with `let`\n factory.'
class Foo(Injector):
pass
assert issubclass(Foo.let(), Foo)<|docstring|>`Injector` subclass can produce its own subclasses with `let`
factory.<|endoftext|>
|
be0e2ba3a924c3b0ded3edd22fe8fd690243504271c4f02f2061da36ee4c8152
|
def test_let_factory_overwrite_dependencies():
'`Injector.let` produce `Injector` subclass with overwritten\n dependencies.'
class Foo(Injector):
bar = 1
assert (Foo.let(bar=2).bar == 2)
|
`Injector.let` produce `Injector` subclass with overwritten
dependencies.
|
tests/test_injector.py
|
test_let_factory_overwrite_dependencies
|
hyperleex/dependencies
| 0
|
python
|
def test_let_factory_overwrite_dependencies():
'`Injector.let` produce `Injector` subclass with overwritten\n dependencies.'
class Foo(Injector):
bar = 1
assert (Foo.let(bar=2).bar == 2)
|
def test_let_factory_overwrite_dependencies():
'`Injector.let` produce `Injector` subclass with overwritten\n dependencies.'
class Foo(Injector):
bar = 1
assert (Foo.let(bar=2).bar == 2)<|docstring|>`Injector.let` produce `Injector` subclass with overwritten
dependencies.<|endoftext|>
|
f7072a9cd041e204ce8d1c5f04b76ab629d33f3bcfa19d027a24ae9ad5b7ba7d
|
def test_let_factory_resolve_not_overwritten_dependencies():
"`Injector.let` can resolve dependencies it doesn't touch."
class Foo(Injector):
bar = 1
assert (Foo.let(baz=2).bar == 1)
|
`Injector.let` can resolve dependencies it doesn't touch.
|
tests/test_injector.py
|
test_let_factory_resolve_not_overwritten_dependencies
|
hyperleex/dependencies
| 0
|
python
|
def test_let_factory_resolve_not_overwritten_dependencies():
class Foo(Injector):
bar = 1
assert (Foo.let(baz=2).bar == 1)
|
def test_let_factory_resolve_not_overwritten_dependencies():
class Foo(Injector):
bar = 1
assert (Foo.let(baz=2).bar == 1)<|docstring|>`Injector.let` can resolve dependencies it doesn't touch.<|endoftext|>
|
5d988d2fbd374920f4d684c24947078cbc3e99eee036c82f4138bb6c18b1d6c8
|
def test_let_factory_on_injector_directly():
'Dependencies can be specified with `let` factory applied to `Injector`\n derectly.'
class Foo(object):
def __init__(self, bar):
self.bar = bar
class Bar(object):
def __init__(self, baz):
self.baz = baz
assert (Injector.let(foo=Foo, bar=Bar, baz=1).foo.bar.baz == 1)
|
Dependencies can be specified with `let` factory applied to `Injector`
derectly.
|
tests/test_injector.py
|
test_let_factory_on_injector_directly
|
hyperleex/dependencies
| 0
|
python
|
def test_let_factory_on_injector_directly():
'Dependencies can be specified with `let` factory applied to `Injector`\n derectly.'
class Foo(object):
def __init__(self, bar):
self.bar = bar
class Bar(object):
def __init__(self, baz):
self.baz = baz
assert (Injector.let(foo=Foo, bar=Bar, baz=1).foo.bar.baz == 1)
|
def test_let_factory_on_injector_directly():
'Dependencies can be specified with `let` factory applied to `Injector`\n derectly.'
class Foo(object):
def __init__(self, bar):
self.bar = bar
class Bar(object):
def __init__(self, baz):
self.baz = baz
assert (Injector.let(foo=Foo, bar=Bar, baz=1).foo.bar.baz == 1)<|docstring|>Dependencies can be specified with `let` factory applied to `Injector`
derectly.<|endoftext|>
|
2cecfc2a69650087485a67e04cabd6bd85e4d55491fb095d5760b69f9855d2d2
|
def test_show_common_class_attributes_with_dir():
'`dir` show common class attributes.'
class Common(object):
pass
class Foo(Injector):
pass
assert ((dir(Common) + ['let']) == dir(Foo))
|
`dir` show common class attributes.
|
tests/test_injector.py
|
test_show_common_class_attributes_with_dir
|
hyperleex/dependencies
| 0
|
python
|
def test_show_common_class_attributes_with_dir():
class Common(object):
pass
class Foo(Injector):
pass
assert ((dir(Common) + ['let']) == dir(Foo))
|
def test_show_common_class_attributes_with_dir():
class Common(object):
pass
class Foo(Injector):
pass
assert ((dir(Common) + ['let']) == dir(Foo))<|docstring|>`dir` show common class attributes.<|endoftext|>
|
efceeb3bf66f66f680f4f0ac49559fce35180a5c6ad9f2f7d73016e653d7b849
|
def test_show_injected_dependencies_with_dir():
'`dir` should show injected dependencies and hide `__dependencies__`\n container.'
class Foo(Injector):
x = 1
assert ('x' in dir(Foo))
assert ('__dependencies__' not in dir(Foo))
|
`dir` should show injected dependencies and hide `__dependencies__`
container.
|
tests/test_injector.py
|
test_show_injected_dependencies_with_dir
|
hyperleex/dependencies
| 0
|
python
|
def test_show_injected_dependencies_with_dir():
'`dir` should show injected dependencies and hide `__dependencies__`\n container.'
class Foo(Injector):
x = 1
assert ('x' in dir(Foo))
assert ('__dependencies__' not in dir(Foo))
|
def test_show_injected_dependencies_with_dir():
'`dir` should show injected dependencies and hide `__dependencies__`\n container.'
class Foo(Injector):
x = 1
assert ('x' in dir(Foo))
assert ('__dependencies__' not in dir(Foo))<|docstring|>`dir` should show injected dependencies and hide `__dependencies__`
container.<|endoftext|>
|
e1b61680b62e95b955a104607a5ce1c38fb215878bc4b27b0288012f0a05692e
|
def test_show_injected_dependencies_with_dir_once():
'Do not repeat injected dependencies in the inheritance chain.'
class Foo(Injector):
x = 1
class Bar(Foo):
x = 2
assert (dir(Bar).count('x') == 1)
|
Do not repeat injected dependencies in the inheritance chain.
|
tests/test_injector.py
|
test_show_injected_dependencies_with_dir_once
|
hyperleex/dependencies
| 0
|
python
|
def test_show_injected_dependencies_with_dir_once():
class Foo(Injector):
x = 1
class Bar(Foo):
x = 2
assert (dir(Bar).count('x') == 1)
|
def test_show_injected_dependencies_with_dir_once():
class Foo(Injector):
x = 1
class Bar(Foo):
x = 2
assert (dir(Bar).count('x') == 1)<|docstring|>Do not repeat injected dependencies in the inheritance chain.<|endoftext|>
|
c14aae20229b192b92b7182ccc541137fefefb8a83f099e9b20583b77ad8c060
|
def test_show_let_dependencies_with_dir():
'`dir` show dependencies injected with `let`.'
assert ('x' in dir(Injector.let(x=1)))
class Foo(Injector):
pass
assert ('x' in dir(Foo.let(x=1)))
|
`dir` show dependencies injected with `let`.
|
tests/test_injector.py
|
test_show_let_dependencies_with_dir
|
hyperleex/dependencies
| 0
|
python
|
def test_show_let_dependencies_with_dir():
assert ('x' in dir(Injector.let(x=1)))
class Foo(Injector):
pass
assert ('x' in dir(Foo.let(x=1)))
|
def test_show_let_dependencies_with_dir():
assert ('x' in dir(Injector.let(x=1)))
class Foo(Injector):
pass
assert ('x' in dir(Foo.let(x=1)))<|docstring|>`dir` show dependencies injected with `let`.<|endoftext|>
|
a38dcc52882ef41b8a0c22b368a502c0623d2adb07032fa73fd59c41d1c5e151
|
def test_omit_parent_link_in_dir_listing():
"Don't show `__parent__` link in the `dir` output.\n\n It is an implementation detail.\n "
class Foo(Injector):
class Bar(Injector):
pass
assert ('__parent__' not in dir(Foo.Bar))
|
Don't show `__parent__` link in the `dir` output.
It is an implementation detail.
|
tests/test_injector.py
|
test_omit_parent_link_in_dir_listing
|
hyperleex/dependencies
| 0
|
python
|
def test_omit_parent_link_in_dir_listing():
"Don't show `__parent__` link in the `dir` output.\n\n It is an implementation detail.\n "
class Foo(Injector):
class Bar(Injector):
pass
assert ('__parent__' not in dir(Foo.Bar))
|
def test_omit_parent_link_in_dir_listing():
"Don't show `__parent__` link in the `dir` output.\n\n It is an implementation detail.\n "
class Foo(Injector):
class Bar(Injector):
pass
assert ('__parent__' not in dir(Foo.Bar))<|docstring|>Don't show `__parent__` link in the `dir` output.
It is an implementation detail.<|endoftext|>
|
c91bfdb09e05b38ef7fe5818268478093904e10fc5ab44a32fa5144f3c50d898
|
@attribute_assignment.parametrize
def test_deny_injector_changes(code):
'Explicitly deny change of any kind on `Injector` and its subclasses.'
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) == "'Injector' modification is not allowed")
|
Explicitly deny change of any kind on `Injector` and its subclasses.
|
tests/test_injector.py
|
test_deny_injector_changes
|
hyperleex/dependencies
| 0
|
python
|
@attribute_assignment.parametrize
def test_deny_injector_changes(code):
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) == "'Injector' modification is not allowed")
|
@attribute_assignment.parametrize
def test_deny_injector_changes(code):
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) == "'Injector' modification is not allowed")<|docstring|>Explicitly deny change of any kind on `Injector` and its subclasses.<|endoftext|>
|
ba2655b2f1459cb8290a1fa33fe3f536f97d7c57c13f4087f81d7f7447e0c8c7
|
@attribute_assignment
def mvT9oyJdXhzh():
'Attribute assignment.'
class Container(Injector):
pass
Container.foo = 1
|
Attribute assignment.
|
tests/test_injector.py
|
mvT9oyJdXhzh
|
hyperleex/dependencies
| 0
|
python
|
@attribute_assignment
def mvT9oyJdXhzh():
class Container(Injector):
pass
Container.foo = 1
|
@attribute_assignment
def mvT9oyJdXhzh():
class Container(Injector):
pass
Container.foo = 1<|docstring|>Attribute assignment.<|endoftext|>
|
5ea3449f000778144ebc263cb52d389ceecfe1cb7d67ef7c29cfbab1b382fc15
|
@attribute_assignment
def fXxRX4KFUc8q():
'Direct assignmet to the `Injector`.'
Injector.foo = 1
|
Direct assignmet to the `Injector`.
|
tests/test_injector.py
|
fXxRX4KFUc8q
|
hyperleex/dependencies
| 0
|
python
|
@attribute_assignment
def fXxRX4KFUc8q():
Injector.foo = 1
|
@attribute_assignment
def fXxRX4KFUc8q():
Injector.foo = 1<|docstring|>Direct assignmet to the `Injector`.<|endoftext|>
|
902f5a099a3bfb685d9eb5df34a01ea78b61a25d965bd54f299a9fb47f55f63c
|
@attribute_assignment
def pHfF0rbEjCsV():
'Let notation.'
Container = Injector.let()
Container.foo = 1
|
Let notation.
|
tests/test_injector.py
|
pHfF0rbEjCsV
|
hyperleex/dependencies
| 0
|
python
|
@attribute_assignment
def pHfF0rbEjCsV():
Container = Injector.let()
Container.foo = 1
|
@attribute_assignment
def pHfF0rbEjCsV():
Container = Injector.let()
Container.foo = 1<|docstring|>Let notation.<|endoftext|>
|
6704bcb1b743ae8d1b3e117b523f4fcc7a61a5ffa234928522561fc3af53e2fc
|
@attribute_assignment
def xhZaIhujf34t():
'Delete attribute.'
class Container(Injector):
foo = 1
del Container.foo
|
Delete attribute.
|
tests/test_injector.py
|
xhZaIhujf34t
|
hyperleex/dependencies
| 0
|
python
|
@attribute_assignment
def xhZaIhujf34t():
class Container(Injector):
foo = 1
del Container.foo
|
@attribute_assignment
def xhZaIhujf34t():
class Container(Injector):
foo = 1
del Container.foo<|docstring|>Delete attribute.<|endoftext|>
|
d5c30a40818898ea923cd1e68ab1dad691b1e494d61fd1fe0bfed9cd0f0a5581
|
@attribute_assignment
def jShuBfttg97c():
'Delete attribute let notation.'
Container = Injector.let(foo=1)
del Container.foo
|
Delete attribute let notation.
|
tests/test_injector.py
|
jShuBfttg97c
|
hyperleex/dependencies
| 0
|
python
|
@attribute_assignment
def jShuBfttg97c():
Container = Injector.let(foo=1)
del Container.foo
|
@attribute_assignment
def jShuBfttg97c():
Container = Injector.let(foo=1)
del Container.foo<|docstring|>Delete attribute let notation.<|endoftext|>
|
8dc30843db4afc80c9de5c0854ce08ecf9339ce6815d9f53981c64433175430f
|
@attribute_assignment
def tQeRzD5ZsyTm():
'Delete attribute from `Injector` directly.'
del Injector.let
|
Delete attribute from `Injector` directly.
|
tests/test_injector.py
|
tQeRzD5ZsyTm
|
hyperleex/dependencies
| 0
|
python
|
@attribute_assignment
def tQeRzD5ZsyTm():
del Injector.let
|
@attribute_assignment
def tQeRzD5ZsyTm():
del Injector.let<|docstring|>Delete attribute from `Injector` directly.<|endoftext|>
|
912e78b653f05284caf859945b5028ea0761585065229af10a9626f65130a3dc
|
def test_nested_injectors():
'It is possible to use `Injector` subclass as attribute in the another\n `Injector` subclass.'
def do_x(a, b):
return (a + b)
def do_y(c, d):
return (c * d)
class Call(object):
def __init__(self, foo, bar):
self.foo = foo
self.bar = bar
def __call__(self, one, two, three):
return self.bar.y(self.foo.x(one, two), three)
class Foo(Injector):
x = do_x
class Bar(Injector):
y = do_y
class Baz(Injector):
foo = Foo
bar = Bar
do = Call
assert (Baz.do(1, 2, 3) == 9)
|
It is possible to use `Injector` subclass as attribute in the another
`Injector` subclass.
|
tests/test_injector.py
|
test_nested_injectors
|
hyperleex/dependencies
| 0
|
python
|
def test_nested_injectors():
'It is possible to use `Injector` subclass as attribute in the another\n `Injector` subclass.'
def do_x(a, b):
return (a + b)
def do_y(c, d):
return (c * d)
class Call(object):
def __init__(self, foo, bar):
self.foo = foo
self.bar = bar
def __call__(self, one, two, three):
return self.bar.y(self.foo.x(one, two), three)
class Foo(Injector):
x = do_x
class Bar(Injector):
y = do_y
class Baz(Injector):
foo = Foo
bar = Bar
do = Call
assert (Baz.do(1, 2, 3) == 9)
|
def test_nested_injectors():
'It is possible to use `Injector` subclass as attribute in the another\n `Injector` subclass.'
def do_x(a, b):
return (a + b)
def do_y(c, d):
return (c * d)
class Call(object):
def __init__(self, foo, bar):
self.foo = foo
self.bar = bar
def __call__(self, one, two, three):
return self.bar.y(self.foo.x(one, two), three)
class Foo(Injector):
x = do_x
class Bar(Injector):
y = do_y
class Baz(Injector):
foo = Foo
bar = Bar
do = Call
assert (Baz.do(1, 2, 3) == 9)<|docstring|>It is possible to use `Injector` subclass as attribute in the another
`Injector` subclass.<|endoftext|>
|
ae6499bf98f99421949ccf3a83266f8159df1c031a6faf5c9359bcfecdb416b6
|
def test_docstrings():
'Check we can access all API entry points documentation.'
assert (Injector.__doc__ == '\nDefault dependencies specification DSL.\n\nClasses inherited from this class may inject dependencies into classes\nspecified in it namespace.\n')
assert (Injector.let.__doc__ == 'Produce new Injector with some dependencies overwritten.')
assert (DependencyError.__doc__ == 'Broken dependencies configuration error.')
class Foo(Injector):
'New container.'
pass
assert (Foo.__doc__ == 'New container.')
|
Check we can access all API entry points documentation.
|
tests/test_injector.py
|
test_docstrings
|
hyperleex/dependencies
| 0
|
python
|
def test_docstrings():
assert (Injector.__doc__ == '\nDefault dependencies specification DSL.\n\nClasses inherited from this class may inject dependencies into classes\nspecified in it namespace.\n')
assert (Injector.let.__doc__ == 'Produce new Injector with some dependencies overwritten.')
assert (DependencyError.__doc__ == 'Broken dependencies configuration error.')
class Foo(Injector):
'New container.'
pass
assert (Foo.__doc__ == 'New container.')
|
def test_docstrings():
assert (Injector.__doc__ == '\nDefault dependencies specification DSL.\n\nClasses inherited from this class may inject dependencies into classes\nspecified in it namespace.\n')
assert (Injector.let.__doc__ == 'Produce new Injector with some dependencies overwritten.')
assert (DependencyError.__doc__ == 'Broken dependencies configuration error.')
class Foo(Injector):
'New container.'
pass
assert (Foo.__doc__ == 'New container.')<|docstring|>Check we can access all API entry points documentation.<|endoftext|>
|
025a1dc10fc82d485aa6be3e07796adbfad1639e305fc4c9ee609a3b2abd9c44
|
@evaluate_classes.parametrize
def test_evaluate_dependencies_once(code):
'Evaluate each node in the dependencies graph once.'
class A(object):
def __init__(self, b, c):
self.b = b
self.c = c
class B(object):
def __init__(self, d):
self.d = d
class C(object):
def __init__(self, d):
self.d = d
class D(object):
pass
class Container(Injector):
a = A
b = B
c = C
d = D
code(Container)
|
Evaluate each node in the dependencies graph once.
|
tests/test_injector.py
|
test_evaluate_dependencies_once
|
hyperleex/dependencies
| 0
|
python
|
@evaluate_classes.parametrize
def test_evaluate_dependencies_once(code):
class A(object):
def __init__(self, b, c):
self.b = b
self.c = c
class B(object):
def __init__(self, d):
self.d = d
class C(object):
def __init__(self, d):
self.d = d
class D(object):
pass
class Container(Injector):
a = A
b = B
c = C
d = D
code(Container)
|
@evaluate_classes.parametrize
def test_evaluate_dependencies_once(code):
class A(object):
def __init__(self, b, c):
self.b = b
self.c = c
class B(object):
def __init__(self, d):
self.d = d
class C(object):
def __init__(self, d):
self.d = d
class D(object):
pass
class Container(Injector):
a = A
b = B
c = C
d = D
code(Container)<|docstring|>Evaluate each node in the dependencies graph once.<|endoftext|>
|
5de2527761caff1c24934300266c6f3bfea019714a554c14750bd709384c00f5
|
@evaluate_classes
def ea4367450e47(Container):
'Each dependency evaluated once during injection.'
x = Container.a
assert (x.b.d is x.c.d)
|
Each dependency evaluated once during injection.
|
tests/test_injector.py
|
ea4367450e47
|
hyperleex/dependencies
| 0
|
python
|
@evaluate_classes
def ea4367450e47(Container):
x = Container.a
assert (x.b.d is x.c.d)
|
@evaluate_classes
def ea4367450e47(Container):
x = Container.a
assert (x.b.d is x.c.d)<|docstring|>Each dependency evaluated once during injection.<|endoftext|>
|
7f3650ff6923eb9079c757dee5c1cb33388e58494397d56a5c33f2f37c269df2
|
@evaluate_classes
def dd91602f3455(Container):
'We reevaluate each dependency for different injections.'
assert (Container.a.b.d is not Container.a.b.d)
assert (Container.a.b.d is not Container.a.c.d)
|
We reevaluate each dependency for different injections.
|
tests/test_injector.py
|
dd91602f3455
|
hyperleex/dependencies
| 0
|
python
|
@evaluate_classes
def dd91602f3455(Container):
assert (Container.a.b.d is not Container.a.b.d)
assert (Container.a.b.d is not Container.a.c.d)
|
@evaluate_classes
def dd91602f3455(Container):
assert (Container.a.b.d is not Container.a.b.d)
assert (Container.a.b.d is not Container.a.c.d)<|docstring|>We reevaluate each dependency for different injections.<|endoftext|>
|
a598f134219f61908501bf0e274d423a0d441a1474b3548c6672734412e6faf4
|
@multiple_inheritance.parametrize
def test_multiple_inheritance(code):
'We can mix injector together.'
class Foo(object):
pass
class Bar(object):
def __init__(self, foo):
self.foo = foo
class Baz(object):
def __init__(self, bar):
self.bar = bar
class FooContainer(Injector):
foo = Foo
class BarContainer(Injector):
bar = Bar
class BazContainer(Injector):
baz = Baz
code(Foo, FooContainer, BarContainer, BazContainer)
|
We can mix injector together.
|
tests/test_injector.py
|
test_multiple_inheritance
|
hyperleex/dependencies
| 0
|
python
|
@multiple_inheritance.parametrize
def test_multiple_inheritance(code):
class Foo(object):
pass
class Bar(object):
def __init__(self, foo):
self.foo = foo
class Baz(object):
def __init__(self, bar):
self.bar = bar
class FooContainer(Injector):
foo = Foo
class BarContainer(Injector):
bar = Bar
class BazContainer(Injector):
baz = Baz
code(Foo, FooContainer, BarContainer, BazContainer)
|
@multiple_inheritance.parametrize
def test_multiple_inheritance(code):
class Foo(object):
pass
class Bar(object):
def __init__(self, foo):
self.foo = foo
class Baz(object):
def __init__(self, bar):
self.bar = bar
class FooContainer(Injector):
foo = Foo
class BarContainer(Injector):
bar = Bar
class BazContainer(Injector):
baz = Baz
code(Foo, FooContainer, BarContainer, BazContainer)<|docstring|>We can mix injector together.<|endoftext|>
|
779b2e4457615b5025a3cb93544e31f41b01584958b039843b7a30af825a790e
|
@multiple_inheritance
def edf946cc6077(Foo, FooContainer, BarContainer, BazContainer):
'Inheritance.'
class Container(FooContainer, BarContainer, BazContainer):
pass
assert isinstance(Container.baz.bar.foo, Foo)
|
Inheritance.
|
tests/test_injector.py
|
edf946cc6077
|
hyperleex/dependencies
| 0
|
python
|
@multiple_inheritance
def edf946cc6077(Foo, FooContainer, BarContainer, BazContainer):
class Container(FooContainer, BarContainer, BazContainer):
pass
assert isinstance(Container.baz.bar.foo, Foo)
|
@multiple_inheritance
def edf946cc6077(Foo, FooContainer, BarContainer, BazContainer):
class Container(FooContainer, BarContainer, BazContainer):
pass
assert isinstance(Container.baz.bar.foo, Foo)<|docstring|>Inheritance.<|endoftext|>
|
f783ae18605778df8797ceca223a69e9536ef000a4361ebc0a0eb69cff8a22e8
|
@multiple_inheritance
def efdc426cd096(Foo, FooContainer, BarContainer, BazContainer):
'Inplace creation.'
assert isinstance(((FooContainer & BarContainer) & BazContainer).baz.bar.foo, Foo)
|
Inplace creation.
|
tests/test_injector.py
|
efdc426cd096
|
hyperleex/dependencies
| 0
|
python
|
@multiple_inheritance
def efdc426cd096(Foo, FooContainer, BarContainer, BazContainer):
assert isinstance(((FooContainer & BarContainer) & BazContainer).baz.bar.foo, Foo)
|
@multiple_inheritance
def efdc426cd096(Foo, FooContainer, BarContainer, BazContainer):
assert isinstance(((FooContainer & BarContainer) & BazContainer).baz.bar.foo, Foo)<|docstring|>Inplace creation.<|endoftext|>
|
c8f2d3ab6f4ff00b7dd875e8dab2938976249a1ac38ce9ebb11dc8fc2266b42e
|
@inheritance_order.parametrize
def test_multiple_inheritance_injectors_order(code):
'`Injector` which comes first in the subclass bases or inplace creation\n must have higher precedence.'
class Container1(Injector):
x = 1
class Container2(Injector):
x = 2
class Container3(Injector):
x = 3
code(Container1, Container2, Container3)
|
`Injector` which comes first in the subclass bases or inplace creation
must have higher precedence.
|
tests/test_injector.py
|
test_multiple_inheritance_injectors_order
|
hyperleex/dependencies
| 0
|
python
|
@inheritance_order.parametrize
def test_multiple_inheritance_injectors_order(code):
'`Injector` which comes first in the subclass bases or inplace creation\n must have higher precedence.'
class Container1(Injector):
x = 1
class Container2(Injector):
x = 2
class Container3(Injector):
x = 3
code(Container1, Container2, Container3)
|
@inheritance_order.parametrize
def test_multiple_inheritance_injectors_order(code):
'`Injector` which comes first in the subclass bases or inplace creation\n must have higher precedence.'
class Container1(Injector):
x = 1
class Container2(Injector):
x = 2
class Container3(Injector):
x = 3
code(Container1, Container2, Container3)<|docstring|>`Injector` which comes first in the subclass bases or inplace creation
must have higher precedence.<|endoftext|>
|
e8498d41ee0e55e988e7117867ab1c16fff64cccc55998a5942218fb6fd204dc
|
@inheritance_order
def aa10c7747a1f(Container1, Container2, Container3):
'Inheritance.'
class Foo(Container1, Container2, Container3):
pass
assert (Foo.x == 1)
|
Inheritance.
|
tests/test_injector.py
|
aa10c7747a1f
|
hyperleex/dependencies
| 0
|
python
|
@inheritance_order
def aa10c7747a1f(Container1, Container2, Container3):
class Foo(Container1, Container2, Container3):
pass
assert (Foo.x == 1)
|
@inheritance_order
def aa10c7747a1f(Container1, Container2, Container3):
class Foo(Container1, Container2, Container3):
pass
assert (Foo.x == 1)<|docstring|>Inheritance.<|endoftext|>
|
86fba4c2b68b4ff8c5e180bc79c583360c5523343769041c6d1c75c94b9d02b7
|
@inheritance_order
def e056e22f3fd5(Container1, Container2, Container3):
'Inheritance with own attributes.'
class Foo(Container1, Container2, Container3):
x = 4
assert (Foo.x == 4)
|
Inheritance with own attributes.
|
tests/test_injector.py
|
e056e22f3fd5
|
hyperleex/dependencies
| 0
|
python
|
@inheritance_order
def e056e22f3fd5(Container1, Container2, Container3):
class Foo(Container1, Container2, Container3):
x = 4
assert (Foo.x == 4)
|
@inheritance_order
def e056e22f3fd5(Container1, Container2, Container3):
class Foo(Container1, Container2, Container3):
x = 4
assert (Foo.x == 4)<|docstring|>Inheritance with own attributes.<|endoftext|>
|
f81551597bde619b1b13d172c748a813b8ea9effe4aa3ef615210fa1e74b3914
|
@inheritance_order
def d851e0414bdf(Container1, Container2, Container3):
'Inplace creation.'
assert (((Container1 & Container2) & Container3).x == 1)
|
Inplace creation.
|
tests/test_injector.py
|
d851e0414bdf
|
hyperleex/dependencies
| 0
|
python
|
@inheritance_order
def d851e0414bdf(Container1, Container2, Container3):
assert (((Container1 & Container2) & Container3).x == 1)
|
@inheritance_order
def d851e0414bdf(Container1, Container2, Container3):
assert (((Container1 & Container2) & Container3).x == 1)<|docstring|>Inplace creation.<|endoftext|>
|
3286b710b8685b0ac0e81f794d873a0e818257351ffaff85eb88c69a49d75c8d
|
@subclasses_only.parametrize
def test_multiple_inheritance_deny_regular_classes(code):
"We can't use classes in multiple inheritance which are not `Injector`\n subclasses."
class Foo(object):
pass
with pytest.raises(DependencyError) as exc_info:
code(Foo)
message = str(exc_info.value)
assert (message == 'Multiple inheritance is allowed for Injector subclasses only')
|
We can't use classes in multiple inheritance which are not `Injector`
subclasses.
|
tests/test_injector.py
|
test_multiple_inheritance_deny_regular_classes
|
hyperleex/dependencies
| 0
|
python
|
@subclasses_only.parametrize
def test_multiple_inheritance_deny_regular_classes(code):
"We can't use classes in multiple inheritance which are not `Injector`\n subclasses."
class Foo(object):
pass
with pytest.raises(DependencyError) as exc_info:
code(Foo)
message = str(exc_info.value)
assert (message == 'Multiple inheritance is allowed for Injector subclasses only')
|
@subclasses_only.parametrize
def test_multiple_inheritance_deny_regular_classes(code):
"We can't use classes in multiple inheritance which are not `Injector`\n subclasses."
class Foo(object):
pass
with pytest.raises(DependencyError) as exc_info:
code(Foo)
message = str(exc_info.value)
assert (message == 'Multiple inheritance is allowed for Injector subclasses only')<|docstring|>We can't use classes in multiple inheritance which are not `Injector`
subclasses.<|endoftext|>
|
039dc5b685ce8a2e965916c2f7ec908882c85ed21e6b3e22a1addab55da5b463
|
@subclasses_only
def f1583394f1a6(Foo):
'Inheritance.'
class Bar(Injector, Foo):
pass
|
Inheritance.
|
tests/test_injector.py
|
f1583394f1a6
|
hyperleex/dependencies
| 0
|
python
|
@subclasses_only
def f1583394f1a6(Foo):
class Bar(Injector, Foo):
pass
|
@subclasses_only
def f1583394f1a6(Foo):
class Bar(Injector, Foo):
pass<|docstring|>Inheritance.<|endoftext|>
|
ff02964b9f1b084590ad932b513c144d2a5866d08fbf4eec78aa6d36e90b5f64
|
@subclasses_only
def b51814725d07(Foo):
'Inplace creation.'
(Injector & Foo)
|
Inplace creation.
|
tests/test_injector.py
|
b51814725d07
|
hyperleex/dependencies
| 0
|
python
|
@subclasses_only
def b51814725d07(Foo):
(Injector & Foo)
|
@subclasses_only
def b51814725d07(Foo):
(Injector & Foo)<|docstring|>Inplace creation.<|endoftext|>
|
762f0f601c4955866d522bf9728c9e40860cddc69a9c6f5b28957bd09a9aee20
|
@deny_magic_methods.parametrize
def test_deny_magic_methods_injection(code):
"`Injector` doesn't accept magic methods."
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) == 'Magic methods are not allowed')
|
`Injector` doesn't accept magic methods.
|
tests/test_injector.py
|
test_deny_magic_methods_injection
|
hyperleex/dependencies
| 0
|
python
|
@deny_magic_methods.parametrize
def test_deny_magic_methods_injection(code):
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) == 'Magic methods are not allowed')
|
@deny_magic_methods.parametrize
def test_deny_magic_methods_injection(code):
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) == 'Magic methods are not allowed')<|docstring|>`Injector` doesn't accept magic methods.<|endoftext|>
|
c4b20333bd4b37f156a52d3611032ad388d3a5dccfad1b1ecafb2f9305dc4d27
|
@deny_magic_methods
def e78bf771747c():
'Declarative injector.'
class Bar(Injector):
def __eq__(self, other):
pass
|
Declarative injector.
|
tests/test_injector.py
|
e78bf771747c
|
hyperleex/dependencies
| 0
|
python
|
@deny_magic_methods
def e78bf771747c():
class Bar(Injector):
def __eq__(self, other):
pass
|
@deny_magic_methods
def e78bf771747c():
class Bar(Injector):
def __eq__(self, other):
pass<|docstring|>Declarative injector.<|endoftext|>
|
c74f86b4d60c26d4aae69150736a7140fb79a74645845228b2043507d7018090
|
@deny_magic_methods
def e34b88041f64():
'Let notation.'
class Foo(Injector):
pass
def eq(self, other):
pass
Foo.let(__eq__=eq)
|
Let notation.
|
tests/test_injector.py
|
e34b88041f64
|
hyperleex/dependencies
| 0
|
python
|
@deny_magic_methods
def e34b88041f64():
class Foo(Injector):
pass
def eq(self, other):
pass
Foo.let(__eq__=eq)
|
@deny_magic_methods
def e34b88041f64():
class Foo(Injector):
pass
def eq(self, other):
pass
Foo.let(__eq__=eq)<|docstring|>Let notation.<|endoftext|>
|
8249c543e694ea5231a11af279417e017e62ca1618ab9b8e920518e0f4c0d6a6
|
@attribute_error.parametrize
def test_attribute_error(code):
"Raise `DependencyError` if we can't find dependency."
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) in {"'Foo' can not resolve attribute 'test'", "'Injector' can not resolve attribute 'test'"})
|
Raise `DependencyError` if we can't find dependency.
|
tests/test_injector.py
|
test_attribute_error
|
hyperleex/dependencies
| 0
|
python
|
@attribute_error.parametrize
def test_attribute_error(code):
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) in {"'Foo' can not resolve attribute 'test'", "'Injector' can not resolve attribute 'test'"})
|
@attribute_error.parametrize
def test_attribute_error(code):
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) in {"'Foo' can not resolve attribute 'test'", "'Injector' can not resolve attribute 'test'"})<|docstring|>Raise `DependencyError` if we can't find dependency.<|endoftext|>
|
05b5982cd5e6fd8f8c5279f3bf259312303126afdc18441d2974407a0297a09b
|
@attribute_error
def c58b054bfcd0():
'Declarative injector.'
class Foo(Injector):
pass
Foo.test
|
Declarative injector.
|
tests/test_injector.py
|
c58b054bfcd0
|
hyperleex/dependencies
| 0
|
python
|
@attribute_error
def c58b054bfcd0():
class Foo(Injector):
pass
Foo.test
|
@attribute_error
def c58b054bfcd0():
class Foo(Injector):
pass
Foo.test<|docstring|>Declarative injector.<|endoftext|>
|
e9eee691ad0cb77d9c04d323c7aa579390d50000dfb2dd30df7ae8b7e63eabd6
|
@attribute_error
def f9c50c81e8c9():
'Let notation.'
Foo = Injector.let()
Foo.test
|
Let notation.
|
tests/test_injector.py
|
f9c50c81e8c9
|
hyperleex/dependencies
| 0
|
python
|
@attribute_error
def f9c50c81e8c9():
Foo = Injector.let()
Foo.test
|
@attribute_error
def f9c50c81e8c9():
Foo = Injector.let()
Foo.test<|docstring|>Let notation.<|endoftext|>
|
24898acbe20c9786850fcb7e792e08d9acebc94fdbdb5369fcbd7b1be4f694eb
|
@attribute_error
def e2f16596a652():
'Let notation from subclass.'
class Foo(Injector):
pass
Foo.let().test
|
Let notation from subclass.
|
tests/test_injector.py
|
e2f16596a652
|
hyperleex/dependencies
| 0
|
python
|
@attribute_error
def e2f16596a652():
class Foo(Injector):
pass
Foo.let().test
|
@attribute_error
def e2f16596a652():
class Foo(Injector):
pass
Foo.let().test<|docstring|>Let notation from subclass.<|endoftext|>
|
8a3634e4a66f13ba0baf7bd0367f5e9bdf8765baaf32b7a37c376651bdd7df00
|
@incomplete_dependencies.parametrize
def test_incomplete_dependencies_error(code):
"Raise `DependencyError` if we can't find dependency."
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) in {"'Foo' can not resolve attribute 'test' while building 'bar'", "'Injector' can not resolve attribute 'test' while building 'bar'"})
|
Raise `DependencyError` if we can't find dependency.
|
tests/test_injector.py
|
test_incomplete_dependencies_error
|
hyperleex/dependencies
| 0
|
python
|
@incomplete_dependencies.parametrize
def test_incomplete_dependencies_error(code):
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) in {"'Foo' can not resolve attribute 'test' while building 'bar'", "'Injector' can not resolve attribute 'test' while building 'bar'"})
|
@incomplete_dependencies.parametrize
def test_incomplete_dependencies_error(code):
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) in {"'Foo' can not resolve attribute 'test' while building 'bar'", "'Injector' can not resolve attribute 'test' while building 'bar'"})<|docstring|>Raise `DependencyError` if we can't find dependency.<|endoftext|>
|
655176286504029ef26b7ed994d450141bc12357bb05c1c2efb7a1a3ee29aae3
|
@incomplete_dependencies
def c4e7ecf75167():
'Keyword arguments in the constructor.'
class Bar(object):
def __init__(self, test, two=2):
pass
class Foo(Injector):
bar = Bar
Foo.bar
|
Keyword arguments in the constructor.
|
tests/test_injector.py
|
c4e7ecf75167
|
hyperleex/dependencies
| 0
|
python
|
@incomplete_dependencies
def c4e7ecf75167():
class Bar(object):
def __init__(self, test, two=2):
pass
class Foo(Injector):
bar = Bar
Foo.bar
|
@incomplete_dependencies
def c4e7ecf75167():
class Bar(object):
def __init__(self, test, two=2):
pass
class Foo(Injector):
bar = Bar
Foo.bar<|docstring|>Keyword arguments in the constructor.<|endoftext|>
|
fca9b99a51f23159e8efa3ab1f0021525764e0bc515f1e3c39e837d78c7b8a18
|
@incomplete_dependencies
def dmsMgYqbsHgB():
'Constructor argument with let notation.'
class Bar(object):
def __init__(self, test):
pass
Foo = Injector.let(bar=Bar)
Foo.bar
|
Constructor argument with let notation.
|
tests/test_injector.py
|
dmsMgYqbsHgB
|
hyperleex/dependencies
| 0
|
python
|
@incomplete_dependencies
def dmsMgYqbsHgB():
class Bar(object):
def __init__(self, test):
pass
Foo = Injector.let(bar=Bar)
Foo.bar
|
@incomplete_dependencies
def dmsMgYqbsHgB():
class Bar(object):
def __init__(self, test):
pass
Foo = Injector.let(bar=Bar)
Foo.bar<|docstring|>Constructor argument with let notation.<|endoftext|>
|
a109342944ee0910ddb88b9dfe61d378f12f1c05b8c15500f2845aa29fb4843f
|
@has_attribute.parametrize
def test_has_attribute(code):
'`Injector` should support `in` statement.'
container = code()
assert ('foo' in container)
assert ('bar' not in container)
|
`Injector` should support `in` statement.
|
tests/test_injector.py
|
test_has_attribute
|
hyperleex/dependencies
| 0
|
python
|
@has_attribute.parametrize
def test_has_attribute(code):
container = code()
assert ('foo' in container)
assert ('bar' not in container)
|
@has_attribute.parametrize
def test_has_attribute(code):
container = code()
assert ('foo' in container)
assert ('bar' not in container)<|docstring|>`Injector` should support `in` statement.<|endoftext|>
|
7f1565064abd78556d334bb132cfa93e7c13d30478a3e8ea5df2627d1afd31ab
|
@has_attribute
def gwufxYkhURAF():
'Declarative injector.'
class Container(Injector):
foo = 1
return Container
|
Declarative injector.
|
tests/test_injector.py
|
gwufxYkhURAF
|
hyperleex/dependencies
| 0
|
python
|
@has_attribute
def gwufxYkhURAF():
class Container(Injector):
foo = 1
return Container
|
@has_attribute
def gwufxYkhURAF():
class Container(Injector):
foo = 1
return Container<|docstring|>Declarative injector.<|endoftext|>
|
fd46e5c00b383bf39e6b9cf80706fe35f4de2b65f455576531a2940cc80cada2
|
@has_attribute
def zlZoLka31ndk():
'Let notation.'
return Injector.let(foo=1)
|
Let notation.
|
tests/test_injector.py
|
zlZoLka31ndk
|
hyperleex/dependencies
| 0
|
python
|
@has_attribute
def zlZoLka31ndk():
return Injector.let(foo=1)
|
@has_attribute
def zlZoLka31ndk():
return Injector.let(foo=1)<|docstring|>Let notation.<|endoftext|>
|
dc424ae83db9cfea23972dcffd04bf0d64086b0dddb497ee0a7af97439a4b039
|
@deny_varargs.parametrize
def test_deny_arbitrary_argument_list(code):
'Raise `DependencyError` if constructor have *args argument.'
class Foo(object):
def __init__(self, *args):
pass
with pytest.raises(DependencyError) as exc_info:
code(Foo)
message = str(exc_info.value)
assert (message == 'Foo.__init__ have arbitrary argument list')
|
Raise `DependencyError` if constructor have *args argument.
|
tests/test_injector.py
|
test_deny_arbitrary_argument_list
|
hyperleex/dependencies
| 0
|
python
|
@deny_varargs.parametrize
def test_deny_arbitrary_argument_list(code):
class Foo(object):
def __init__(self, *args):
pass
with pytest.raises(DependencyError) as exc_info:
code(Foo)
message = str(exc_info.value)
assert (message == 'Foo.__init__ have arbitrary argument list')
|
@deny_varargs.parametrize
def test_deny_arbitrary_argument_list(code):
class Foo(object):
def __init__(self, *args):
pass
with pytest.raises(DependencyError) as exc_info:
code(Foo)
message = str(exc_info.value)
assert (message == 'Foo.__init__ have arbitrary argument list')<|docstring|>Raise `DependencyError` if constructor have *args argument.<|endoftext|>
|
a28ee4198e26383383a0d924319ce9891165ff35d41ac7e524c860cce7d36590
|
@deny_varargs
def dfe1c22c641e(Foo):
'Declarative injector.'
class Summator(Injector):
foo = Foo
args = (1, 2, 3)
|
Declarative injector.
|
tests/test_injector.py
|
dfe1c22c641e
|
hyperleex/dependencies
| 0
|
python
|
@deny_varargs
def dfe1c22c641e(Foo):
class Summator(Injector):
foo = Foo
args = (1, 2, 3)
|
@deny_varargs
def dfe1c22c641e(Foo):
class Summator(Injector):
foo = Foo
args = (1, 2, 3)<|docstring|>Declarative injector.<|endoftext|>
|
8bc3d33e6434881bdd115cd3f5434c79255bc2908b2c03f3c706aed2236a503e
|
@deny_varargs
def f7ef2aa82c18(Foo):
'Let notation.'
Injector.let(foo=Foo, args=(1, 2, 3))
|
Let notation.
|
tests/test_injector.py
|
f7ef2aa82c18
|
hyperleex/dependencies
| 0
|
python
|
@deny_varargs
def f7ef2aa82c18(Foo):
Injector.let(foo=Foo, args=(1, 2, 3))
|
@deny_varargs
def f7ef2aa82c18(Foo):
Injector.let(foo=Foo, args=(1, 2, 3))<|docstring|>Let notation.<|endoftext|>
|
6c80412289829697903dfdcea9599f9f7237b6952a70b22623e45d1f32f469aa
|
@deny_kwargs.parametrize
def test_deny_arbitrary_keyword_arguments(code):
'Raise `DependencyError` if constructor have **kwargs argument.'
class Foo(object):
def __init__(self, **kwargs):
pass
with pytest.raises(DependencyError) as exc_info:
code(Foo)
message = str(exc_info.value)
assert (message == 'Foo.__init__ have arbitrary keyword arguments')
|
Raise `DependencyError` if constructor have **kwargs argument.
|
tests/test_injector.py
|
test_deny_arbitrary_keyword_arguments
|
hyperleex/dependencies
| 0
|
python
|
@deny_kwargs.parametrize
def test_deny_arbitrary_keyword_arguments(code):
class Foo(object):
def __init__(self, **kwargs):
pass
with pytest.raises(DependencyError) as exc_info:
code(Foo)
message = str(exc_info.value)
assert (message == 'Foo.__init__ have arbitrary keyword arguments')
|
@deny_kwargs.parametrize
def test_deny_arbitrary_keyword_arguments(code):
class Foo(object):
def __init__(self, **kwargs):
pass
with pytest.raises(DependencyError) as exc_info:
code(Foo)
message = str(exc_info.value)
assert (message == 'Foo.__init__ have arbitrary keyword arguments')<|docstring|>Raise `DependencyError` if constructor have **kwargs argument.<|endoftext|>
|
7f2aed29fa74e560d9cc935cdaa12c4b614fad5ee848443e9342e383090e7736
|
@deny_kwargs
def e281099be65d(Foo):
'Declarative injector.'
class Summator(Injector):
foo = Foo
kwargs = {'start': 5}
|
Declarative injector.
|
tests/test_injector.py
|
e281099be65d
|
hyperleex/dependencies
| 0
|
python
|
@deny_kwargs
def e281099be65d(Foo):
class Summator(Injector):
foo = Foo
kwargs = {'start': 5}
|
@deny_kwargs
def e281099be65d(Foo):
class Summator(Injector):
foo = Foo
kwargs = {'start': 5}<|docstring|>Declarative injector.<|endoftext|>
|
1fe4956a828aa18f7342b06a42edfdb73ca216e49e92296f4818ecae8a2f77e3
|
@deny_kwargs
def bcf7c5881b2c(Foo):
'Let notation.'
Injector.let(foo=Foo, kwargs={'start': 5})
|
Let notation.
|
tests/test_injector.py
|
bcf7c5881b2c
|
hyperleex/dependencies
| 0
|
python
|
@deny_kwargs
def bcf7c5881b2c(Foo):
Injector.let(foo=Foo, kwargs={'start': 5})
|
@deny_kwargs
def bcf7c5881b2c(Foo):
Injector.let(foo=Foo, kwargs={'start': 5})<|docstring|>Let notation.<|endoftext|>
|
a63680bddc3d03c7d0ae014931d0def6f45e2e4c08b265a4079388e67ebf2932
|
@deny_varargs_kwargs.parametrize
def test_deny_arbitrary_positional_and_keyword_arguments_together(code):
'Raise `DependencyError` if constructor have *args and **kwargs\n argument.'
class Foo(object):
def __init__(self, *args, **kwargs):
pass
with pytest.raises(DependencyError) as exc_info:
code(Foo)
message = str(exc_info.value)
assert (message == 'Foo.__init__ have arbitrary argument list and keyword arguments')
|
Raise `DependencyError` if constructor have *args and **kwargs
argument.
|
tests/test_injector.py
|
test_deny_arbitrary_positional_and_keyword_arguments_together
|
hyperleex/dependencies
| 0
|
python
|
@deny_varargs_kwargs.parametrize
def test_deny_arbitrary_positional_and_keyword_arguments_together(code):
'Raise `DependencyError` if constructor have *args and **kwargs\n argument.'
class Foo(object):
def __init__(self, *args, **kwargs):
pass
with pytest.raises(DependencyError) as exc_info:
code(Foo)
message = str(exc_info.value)
assert (message == 'Foo.__init__ have arbitrary argument list and keyword arguments')
|
@deny_varargs_kwargs.parametrize
def test_deny_arbitrary_positional_and_keyword_arguments_together(code):
'Raise `DependencyError` if constructor have *args and **kwargs\n argument.'
class Foo(object):
def __init__(self, *args, **kwargs):
pass
with pytest.raises(DependencyError) as exc_info:
code(Foo)
message = str(exc_info.value)
assert (message == 'Foo.__init__ have arbitrary argument list and keyword arguments')<|docstring|>Raise `DependencyError` if constructor have *args and **kwargs
argument.<|endoftext|>
|
c82d2661c9eb030d7b58a10530a2de7b8ecb0dfa24e37453fb462f3a8d8ff438
|
@deny_varargs_kwargs
def efbf07f8deb6(Foo):
'Declarative injector.'
class Summator(Injector):
foo = Foo
args = (1, 2, 3)
kwargs = {'start': 5}
|
Declarative injector.
|
tests/test_injector.py
|
efbf07f8deb6
|
hyperleex/dependencies
| 0
|
python
|
@deny_varargs_kwargs
def efbf07f8deb6(Foo):
class Summator(Injector):
foo = Foo
args = (1, 2, 3)
kwargs = {'start': 5}
|
@deny_varargs_kwargs
def efbf07f8deb6(Foo):
class Summator(Injector):
foo = Foo
args = (1, 2, 3)
kwargs = {'start': 5}<|docstring|>Declarative injector.<|endoftext|>
|
321200a9f2fb5f6fc94dbce2cc1baf0b4f7e6c9f6377b11a1d5e4b67d2470be2
|
@deny_varargs_kwargs
def c4362558f312(Foo):
'Let notation.'
Injector.let(foo=Foo, args=(1, 2, 3), kwargs={'start': 5})
|
Let notation.
|
tests/test_injector.py
|
c4362558f312
|
hyperleex/dependencies
| 0
|
python
|
@deny_varargs_kwargs
def c4362558f312(Foo):
Injector.let(foo=Foo, args=(1, 2, 3), kwargs={'start': 5})
|
@deny_varargs_kwargs
def c4362558f312(Foo):
Injector.let(foo=Foo, args=(1, 2, 3), kwargs={'start': 5})<|docstring|>Let notation.<|endoftext|>
|
315546675a7bfd6e44f7d0466ca9ce302f9418d58ffc806b68ca846ba2444251
|
@deny_let_redefine.parametrize
def test_deny_to_redefine_let_attribute(code):
"We can't redefine let attribute in the `Injector` subclasses."
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) == "'let' redefinition is not allowed")
|
We can't redefine let attribute in the `Injector` subclasses.
|
tests/test_injector.py
|
test_deny_to_redefine_let_attribute
|
hyperleex/dependencies
| 0
|
python
|
@deny_let_redefine.parametrize
def test_deny_to_redefine_let_attribute(code):
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) == "'let' redefinition is not allowed")
|
@deny_let_redefine.parametrize
def test_deny_to_redefine_let_attribute(code):
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) == "'let' redefinition is not allowed")<|docstring|>We can't redefine let attribute in the `Injector` subclasses.<|endoftext|>
|
6e69c6ac61fc20c8597c77a6a6fd80f3a27b9e5bf8e2e2ba754be24d13100281
|
@deny_let_redefine
def a2bfa842df0c():
'Declarative injector.'
class Foo(Injector):
let = 2
|
Declarative injector.
|
tests/test_injector.py
|
a2bfa842df0c
|
hyperleex/dependencies
| 0
|
python
|
@deny_let_redefine
def a2bfa842df0c():
class Foo(Injector):
let = 2
|
@deny_let_redefine
def a2bfa842df0c():
class Foo(Injector):
let = 2<|docstring|>Declarative injector.<|endoftext|>
|
ad6548d2156f30e02fa22dab6eb24a9926ba3124f609d194cda5a90b21b9edbe
|
@deny_let_redefine
def ddd392e70db6():
'Let notation.'
class Foo(Injector):
pass
Foo.let(let=1)
|
Let notation.
|
tests/test_injector.py
|
ddd392e70db6
|
hyperleex/dependencies
| 0
|
python
|
@deny_let_redefine
def ddd392e70db6():
class Foo(Injector):
pass
Foo.let(let=1)
|
@deny_let_redefine
def ddd392e70db6():
class Foo(Injector):
pass
Foo.let(let=1)<|docstring|>Let notation.<|endoftext|>
|
34544b6277b2d5ebbc1c8447885a16ff3124f1abc7ca10d499f523781e01ad54
|
@deny_call.parametrize
def test_deny_to_instantiate_injector(code):
'Deny injector instantiation.'
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) == 'Do not instantiate Injector')
|
Deny injector instantiation.
|
tests/test_injector.py
|
test_deny_to_instantiate_injector
|
hyperleex/dependencies
| 0
|
python
|
@deny_call.parametrize
def test_deny_to_instantiate_injector(code):
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) == 'Do not instantiate Injector')
|
@deny_call.parametrize
def test_deny_to_instantiate_injector(code):
with pytest.raises(DependencyError) as exc_info:
code()
assert (str(exc_info.value) == 'Do not instantiate Injector')<|docstring|>Deny injector instantiation.<|endoftext|>
|
0a5ddb67556a16e8138ef13d7f65ef08088a52300a329958af99eafb62823c01
|
@deny_call
def ce52d740af31():
'Direct call.'
Injector()
|
Direct call.
|
tests/test_injector.py
|
ce52d740af31
|
hyperleex/dependencies
| 0
|
python
|
@deny_call
def ce52d740af31():
Injector()
|
@deny_call
def ce52d740af31():
Injector()<|docstring|>Direct call.<|endoftext|>
|
9c4eb0f920dbefb19c1906e59c1057f9f7a4052186b17db6a9c764b517b4265e
|
@deny_call
def a95940f44400():
'Subclass call.'
class Foo(Injector):
pass
Foo()
|
Subclass call.
|
tests/test_injector.py
|
a95940f44400
|
hyperleex/dependencies
| 0
|
python
|
@deny_call
def a95940f44400():
class Foo(Injector):
pass
Foo()
|
@deny_call
def a95940f44400():
class Foo(Injector):
pass
Foo()<|docstring|>Subclass call.<|endoftext|>
|
53fe37bd569fce4a5e132344c7d3e0ddc0ced33ed59d64f1bd63dccac6f3b219
|
@deny_call
def d10b4ba474a9():
'Ignore any arguments passed.'
Injector(1)
|
Ignore any arguments passed.
|
tests/test_injector.py
|
d10b4ba474a9
|
hyperleex/dependencies
| 0
|
python
|
@deny_call
def d10b4ba474a9():
Injector(1)
|
@deny_call
def d10b4ba474a9():
Injector(1)<|docstring|>Ignore any arguments passed.<|endoftext|>
|
03ebab7a37e9e7a4f59edf9dd93afe414d1cda13edac59b58c91aef31c7ae50e
|
@deny_call
def d665c722baae():
'Ignore any keyword argument passed.'
Injector(x=1)
|
Ignore any keyword argument passed.
|
tests/test_injector.py
|
d665c722baae
|
hyperleex/dependencies
| 0
|
python
|
@deny_call
def d665c722baae():
Injector(x=1)
|
@deny_call
def d665c722baae():
Injector(x=1)<|docstring|>Ignore any keyword argument passed.<|endoftext|>
|
2e57c33e57547fd198cc4af898eef02893ad5d3f7f8af18cdf2160408bd89ad8
|
@cls_named_arguments.parametrize
def test_deny_classes_as_default_values(code):
"If argument name doesn't ends with `_class`, its default value can't be\n a class."
class Foo(object):
pass
class Bar(object):
def __init__(self, foo=Foo):
pass
with pytest.raises(DependencyError) as exc_info:
code(Foo, Bar)
message = str(exc_info.value)
expected_message = "\n'Bar' class has a default value of 'foo' argument set to 'Foo' class.\n\nYou should either change the name of the argument into 'foo_class'\nor set the default value to an instance of that class.\n".strip()
assert (message == expected_message)
|
If argument name doesn't ends with `_class`, its default value can't be
a class.
|
tests/test_injector.py
|
test_deny_classes_as_default_values
|
hyperleex/dependencies
| 0
|
python
|
@cls_named_arguments.parametrize
def test_deny_classes_as_default_values(code):
"If argument name doesn't ends with `_class`, its default value can't be\n a class."
class Foo(object):
pass
class Bar(object):
def __init__(self, foo=Foo):
pass
with pytest.raises(DependencyError) as exc_info:
code(Foo, Bar)
message = str(exc_info.value)
expected_message = "\n'Bar' class has a default value of 'foo' argument set to 'Foo' class.\n\nYou should either change the name of the argument into 'foo_class'\nor set the default value to an instance of that class.\n".strip()
assert (message == expected_message)
|
@cls_named_arguments.parametrize
def test_deny_classes_as_default_values(code):
"If argument name doesn't ends with `_class`, its default value can't be\n a class."
class Foo(object):
pass
class Bar(object):
def __init__(self, foo=Foo):
pass
with pytest.raises(DependencyError) as exc_info:
code(Foo, Bar)
message = str(exc_info.value)
expected_message = "\n'Bar' class has a default value of 'foo' argument set to 'Foo' class.\n\nYou should either change the name of the argument into 'foo_class'\nor set the default value to an instance of that class.\n".strip()
assert (message == expected_message)<|docstring|>If argument name doesn't ends with `_class`, its default value can't be
a class.<|endoftext|>
|
9972debcf444e1d944a83e4de4eaa70fe11a0a6016e79ebd690782bd4f30e052
|
@cls_named_arguments
def dad79637580d(Foo, Bar):
'Declarative injector.'
class Container(Injector):
bar = Bar
|
Declarative injector.
|
tests/test_injector.py
|
dad79637580d
|
hyperleex/dependencies
| 0
|
python
|
@cls_named_arguments
def dad79637580d(Foo, Bar):
class Container(Injector):
bar = Bar
|
@cls_named_arguments
def dad79637580d(Foo, Bar):
class Container(Injector):
bar = Bar<|docstring|>Declarative injector.<|endoftext|>
|
78e04dc6dc308091b10f5a5e233f5f923b0ecf43b57dc8a215a658a3091b404d
|
@cls_named_arguments
def bccb4f621e70(Foo, Bar):
'Let notation.'
Injector.let(bar=Bar)
|
Let notation.
|
tests/test_injector.py
|
bccb4f621e70
|
hyperleex/dependencies
| 0
|
python
|
@cls_named_arguments
def bccb4f621e70(Foo, Bar):
Injector.let(bar=Bar)
|
@cls_named_arguments
def bccb4f621e70(Foo, Bar):
Injector.let(bar=Bar)<|docstring|>Let notation.<|endoftext|>
|
9a8f93ce493107294130b7e4bcadb305388dc439eb0ca0e71de6202bc4903a8c
|
@cls_named_defaults.parametrize
def test_deny_non_classes_in_class_named_arguments(code):
'If argument name ends with `_class`, it must have a class as it default\n value.'
class Bar(object):
def __init__(self, foo_class=1):
self.foo_class = foo_class
with pytest.raises(DependencyError) as exc_info:
code(Bar)
message = str(exc_info.value)
assert (message == "'foo_class' default value should be a class")
|
If argument name ends with `_class`, it must have a class as it default
value.
|
tests/test_injector.py
|
test_deny_non_classes_in_class_named_arguments
|
hyperleex/dependencies
| 0
|
python
|
@cls_named_defaults.parametrize
def test_deny_non_classes_in_class_named_arguments(code):
'If argument name ends with `_class`, it must have a class as it default\n value.'
class Bar(object):
def __init__(self, foo_class=1):
self.foo_class = foo_class
with pytest.raises(DependencyError) as exc_info:
code(Bar)
message = str(exc_info.value)
assert (message == "'foo_class' default value should be a class")
|
@cls_named_defaults.parametrize
def test_deny_non_classes_in_class_named_arguments(code):
'If argument name ends with `_class`, it must have a class as it default\n value.'
class Bar(object):
def __init__(self, foo_class=1):
self.foo_class = foo_class
with pytest.raises(DependencyError) as exc_info:
code(Bar)
message = str(exc_info.value)
assert (message == "'foo_class' default value should be a class")<|docstring|>If argument name ends with `_class`, it must have a class as it default
value.<|endoftext|>
|
ef80717851eac57ffe8ac04b746f55afc264bc7f7aa2c49c52321d7932dc89a0
|
@cls_named_defaults
def a8cd70341d3d(Bar):
'Declarative injector.'
class Container(Injector):
bar = Bar
|
Declarative injector.
|
tests/test_injector.py
|
a8cd70341d3d
|
hyperleex/dependencies
| 0
|
python
|
@cls_named_defaults
def a8cd70341d3d(Bar):
class Container(Injector):
bar = Bar
|
@cls_named_defaults
def a8cd70341d3d(Bar):
class Container(Injector):
bar = Bar<|docstring|>Declarative injector.<|endoftext|>
|
d4387aebfa3511ca740cd67f1156717778de11a7d11a78ac7223c89e8ee089de
|
@cls_named_defaults
def b859e98f2913(Bar):
'Let notation.'
Injector.let(bar=Bar)
|
Let notation.
|
tests/test_injector.py
|
b859e98f2913
|
hyperleex/dependencies
| 0
|
python
|
@cls_named_defaults
def b859e98f2913(Bar):
Injector.let(bar=Bar)
|
@cls_named_defaults
def b859e98f2913(Bar):
Injector.let(bar=Bar)<|docstring|>Let notation.<|endoftext|>
|
851e3f32814c01676ae49f0fffb19570f4a75b6d1947ef781a2f78a7e2728dc4
|
@pytest.fixture
def test_file_name(request):
'\n create test dependent filename path string\n '
(yield '{}.hkl'.format(request.function.__name__))
|
create test dependent filename path string
|
hickle/tests/test_hickle.py
|
test_file_name
|
texadactyl/hickle
| 0
|
python
|
@pytest.fixture
def test_file_name(request):
'\n \n '
(yield '{}.hkl'.format(request.function.__name__))
|
@pytest.fixture
def test_file_name(request):
'\n \n '
(yield '{}.hkl'.format(request.function.__name__))<|docstring|>create test dependent filename path string<|endoftext|>
|
5f7db1ed9cd15d53912a39e81d79c929f6d08498bb55a3c6a4c48b57724d297c
|
def func(a, b, c=0):
' just something to do '
return (a, b, c)
|
just something to do
|
hickle/tests/test_hickle.py
|
func
|
texadactyl/hickle
| 0
|
python
|
def func(a, b, c=0):
' '
return (a, b, c)
|
def func(a, b, c=0):
' '
return (a, b, c)<|docstring|>just something to do<|endoftext|>
|
78d3394d239116fa2ef6bebcfe13277e9418bed546f94913262edb38220d35d7
|
def make_visible_to_dumps(obj, protocol=None, *, fix_imports=True):
'\n simulate loader functions defined outside hickle package\n '
if (obj in types_to_hide):
obj.__module__ = re.sub('^\\s*(?!hickle\\.)', 'hickle.', obj.__module__)
elif (obj.__class__ in types_to_hide):
obj.__class__.__module__ = re.sub('^\\s*(?!hickle\\.)', 'hickle.', obj.__class__.__module__)
return pickle_dumps(obj, protocol, fix_imports=fix_imports)
|
simulate loader functions defined outside hickle package
|
hickle/tests/test_hickle.py
|
make_visible_to_dumps
|
texadactyl/hickle
| 0
|
python
|
def make_visible_to_dumps(obj, protocol=None, *, fix_imports=True):
'\n \n '
if (obj in types_to_hide):
obj.__module__ = re.sub('^\\s*(?!hickle\\.)', 'hickle.', obj.__module__)
elif (obj.__class__ in types_to_hide):
obj.__class__.__module__ = re.sub('^\\s*(?!hickle\\.)', 'hickle.', obj.__class__.__module__)
return pickle_dumps(obj, protocol, fix_imports=fix_imports)
|
def make_visible_to_dumps(obj, protocol=None, *, fix_imports=True):
'\n \n '
if (obj in types_to_hide):
obj.__module__ = re.sub('^\\s*(?!hickle\\.)', 'hickle.', obj.__module__)
elif (obj.__class__ in types_to_hide):
obj.__class__.__module__ = re.sub('^\\s*(?!hickle\\.)', 'hickle.', obj.__class__.__module__)
return pickle_dumps(obj, protocol, fix_imports=fix_imports)<|docstring|>simulate loader functions defined outside hickle package<|endoftext|>
|
840f22ee592d789f5d22f405401948e9f8cae32be9c58f4114d982e71180b556
|
def hide_from_hickle(bytes_obj, *, fix_imports=True, encoding='ASCII', errors='strict'):
'\n simulate loader function defined outside hickle package\n '
obj = pickle_loads(bytes_obj, fix_imports=fix_imports, encoding=encoding, errors=errors)
if (obj in types_to_hide):
obj.__module__ = re.sub('^\\s*hickle\\.', '', obj.__module__)
elif (obj.__class__ in types_to_hide):
obj.__class__.__module__ = re.sub('^\\s*hickle\\.', '', obj.__class__.__module__)
return obj
|
simulate loader function defined outside hickle package
|
hickle/tests/test_hickle.py
|
hide_from_hickle
|
texadactyl/hickle
| 0
|
python
|
def hide_from_hickle(bytes_obj, *, fix_imports=True, encoding='ASCII', errors='strict'):
'\n \n '
obj = pickle_loads(bytes_obj, fix_imports=fix_imports, encoding=encoding, errors=errors)
if (obj in types_to_hide):
obj.__module__ = re.sub('^\\s*hickle\\.', , obj.__module__)
elif (obj.__class__ in types_to_hide):
obj.__class__.__module__ = re.sub('^\\s*hickle\\.', , obj.__class__.__module__)
return obj
|
def hide_from_hickle(bytes_obj, *, fix_imports=True, encoding='ASCII', errors='strict'):
'\n \n '
obj = pickle_loads(bytes_obj, fix_imports=fix_imports, encoding=encoding, errors=errors)
if (obj in types_to_hide):
obj.__module__ = re.sub('^\\s*hickle\\.', , obj.__module__)
elif (obj.__class__ in types_to_hide):
obj.__class__.__module__ = re.sub('^\\s*hickle\\.', , obj.__class__.__module__)
return obj<|docstring|>simulate loader function defined outside hickle package<|endoftext|>
|
bf5a35cba65165704796db8339d54afa5131c2f842df1d7b48bbfcca18fbe0d9
|
def test_invalid_file():
' Test if trying to use a non-file object fails. '
with pytest.raises(hickle.FileError):
dump('test', ())
|
Test if trying to use a non-file object fails.
|
hickle/tests/test_hickle.py
|
test_invalid_file
|
texadactyl/hickle
| 0
|
python
|
def test_invalid_file():
' '
with pytest.raises(hickle.FileError):
dump('test', ())
|
def test_invalid_file():
' '
with pytest.raises(hickle.FileError):
dump('test', ())<|docstring|>Test if trying to use a non-file object fails.<|endoftext|>
|
7d82d36a00f59a7320648ffbd7ab564fd95bc69abedd29a28094dc242d5dc6d0
|
def test_state_obj(monkeypatch, test_file_name, compression_kwargs):
' Dumping and loading a class object with pickle states\n\n https://github.com/telegraphic/hickle/issues/125'
with monkeypatch.context() as monkey:
monkey.setattr(with_state, '__module__', re.sub('^\\s*hickle\\.', '', with_state.__module__))
monkey.setattr(pickle, 'dumps', make_visible_to_dumps)
mode = 'w'
obj = with_state()
with pytest.warns(lookup.SerializedWarning):
dump(obj, test_file_name, mode, **compression_kwargs)
monkey.setattr(pickle, 'loads', hide_from_hickle)
obj_hkl = load(test_file_name)
assert (isinstance(obj, obj_hkl.__class__) or isinstance(obj_hkl, obj.__class__))
assert np.allclose(obj[1], obj_hkl[1])
|
Dumping and loading a class object with pickle states
https://github.com/telegraphic/hickle/issues/125
|
hickle/tests/test_hickle.py
|
test_state_obj
|
texadactyl/hickle
| 0
|
python
|
def test_state_obj(monkeypatch, test_file_name, compression_kwargs):
' Dumping and loading a class object with pickle states\n\n https://github.com/telegraphic/hickle/issues/125'
with monkeypatch.context() as monkey:
monkey.setattr(with_state, '__module__', re.sub('^\\s*hickle\\.', , with_state.__module__))
monkey.setattr(pickle, 'dumps', make_visible_to_dumps)
mode = 'w'
obj = with_state()
with pytest.warns(lookup.SerializedWarning):
dump(obj, test_file_name, mode, **compression_kwargs)
monkey.setattr(pickle, 'loads', hide_from_hickle)
obj_hkl = load(test_file_name)
assert (isinstance(obj, obj_hkl.__class__) or isinstance(obj_hkl, obj.__class__))
assert np.allclose(obj[1], obj_hkl[1])
|
def test_state_obj(monkeypatch, test_file_name, compression_kwargs):
' Dumping and loading a class object with pickle states\n\n https://github.com/telegraphic/hickle/issues/125'
with monkeypatch.context() as monkey:
monkey.setattr(with_state, '__module__', re.sub('^\\s*hickle\\.', , with_state.__module__))
monkey.setattr(pickle, 'dumps', make_visible_to_dumps)
mode = 'w'
obj = with_state()
with pytest.warns(lookup.SerializedWarning):
dump(obj, test_file_name, mode, **compression_kwargs)
monkey.setattr(pickle, 'loads', hide_from_hickle)
obj_hkl = load(test_file_name)
assert (isinstance(obj, obj_hkl.__class__) or isinstance(obj_hkl, obj.__class__))
assert np.allclose(obj[1], obj_hkl[1])<|docstring|>Dumping and loading a class object with pickle states
https://github.com/telegraphic/hickle/issues/125<|endoftext|>
|
fa5a10509a70369784ec8485c5abbd2047414695c24e1d502076cc1c645da5f1
|
def test_local_func(test_file_name, compression_kwargs):
' Dumping and loading a local function\n\n https://github.com/telegraphic/hickle/issues/119'
mode = 'w'
with pytest.warns(lookup.SerializedWarning):
dump(func, test_file_name, mode, **compression_kwargs)
func_hkl = load(test_file_name)
assert (isinstance(func, func_hkl.__class__) or isinstance(func_hkl, func.__class__))
assert (func(1, 2) == func_hkl(1, 2))
|
Dumping and loading a local function
https://github.com/telegraphic/hickle/issues/119
|
hickle/tests/test_hickle.py
|
test_local_func
|
texadactyl/hickle
| 0
|
python
|
def test_local_func(test_file_name, compression_kwargs):
' Dumping and loading a local function\n\n https://github.com/telegraphic/hickle/issues/119'
mode = 'w'
with pytest.warns(lookup.SerializedWarning):
dump(func, test_file_name, mode, **compression_kwargs)
func_hkl = load(test_file_name)
assert (isinstance(func, func_hkl.__class__) or isinstance(func_hkl, func.__class__))
assert (func(1, 2) == func_hkl(1, 2))
|
def test_local_func(test_file_name, compression_kwargs):
' Dumping and loading a local function\n\n https://github.com/telegraphic/hickle/issues/119'
mode = 'w'
with pytest.warns(lookup.SerializedWarning):
dump(func, test_file_name, mode, **compression_kwargs)
func_hkl = load(test_file_name)
assert (isinstance(func, func_hkl.__class__) or isinstance(func_hkl, func.__class__))
assert (func(1, 2) == func_hkl(1, 2))<|docstring|>Dumping and loading a local function
https://github.com/telegraphic/hickle/issues/119<|endoftext|>
|
d7fc91f722ba1b935917ea797647e69c2332a55678c2262f29381d86e7f4300e
|
def test_non_empty_group(test_file_name, compression_kwargs):
' Test if attempting to dump to a group with data fails '
hickle.dump(None, test_file_name, **compression_kwargs)
with pytest.raises(ValueError):
dump(None, test_file_name, 'r+', **compression_kwargs)
|
Test if attempting to dump to a group with data fails
|
hickle/tests/test_hickle.py
|
test_non_empty_group
|
texadactyl/hickle
| 0
|
python
|
def test_non_empty_group(test_file_name, compression_kwargs):
' '
hickle.dump(None, test_file_name, **compression_kwargs)
with pytest.raises(ValueError):
dump(None, test_file_name, 'r+', **compression_kwargs)
|
def test_non_empty_group(test_file_name, compression_kwargs):
' '
hickle.dump(None, test_file_name, **compression_kwargs)
with pytest.raises(ValueError):
dump(None, test_file_name, 'r+', **compression_kwargs)<|docstring|>Test if attempting to dump to a group with data fails<|endoftext|>
|
ac43964000c5ea5401aeaf60b1a81d8073898c26d627498f6ff20cf236dba1ee
|
def test_string(test_file_name, compression_kwargs):
' Dumping and loading a string '
mode = 'w'
string_obj = 'The quick brown fox jumps over the lazy dog'
dump(string_obj, test_file_name, mode, **compression_kwargs)
string_hkl = load(test_file_name)
assert isinstance(string_hkl, str)
assert (string_obj == string_hkl)
|
Dumping and loading a string
|
hickle/tests/test_hickle.py
|
test_string
|
texadactyl/hickle
| 0
|
python
|
def test_string(test_file_name, compression_kwargs):
' '
mode = 'w'
string_obj = 'The quick brown fox jumps over the lazy dog'
dump(string_obj, test_file_name, mode, **compression_kwargs)
string_hkl = load(test_file_name)
assert isinstance(string_hkl, str)
assert (string_obj == string_hkl)
|
def test_string(test_file_name, compression_kwargs):
' '
mode = 'w'
string_obj = 'The quick brown fox jumps over the lazy dog'
dump(string_obj, test_file_name, mode, **compression_kwargs)
string_hkl = load(test_file_name)
assert isinstance(string_hkl, str)
assert (string_obj == string_hkl)<|docstring|>Dumping and loading a string<|endoftext|>
|
1fed01ea075b64c6a51d4639e374fafeaef27d8b7e5114381023761c671bf827
|
def test_65bit_int(test_file_name, compression_kwargs):
' Dumping and loading an integer with arbitrary precision\n\n https://github.com/telegraphic/hickle/issues/113'
i = ((2 ** 65) - 1)
dump(i, test_file_name, **compression_kwargs)
i_hkl = load(test_file_name)
assert (i == i_hkl)
j = ((- (2 ** 63)) - 1)
dump(j, test_file_name, **compression_kwargs)
j_hkl = load(test_file_name)
assert (j == j_hkl)
|
Dumping and loading an integer with arbitrary precision
https://github.com/telegraphic/hickle/issues/113
|
hickle/tests/test_hickle.py
|
test_65bit_int
|
texadactyl/hickle
| 0
|
python
|
def test_65bit_int(test_file_name, compression_kwargs):
' Dumping and loading an integer with arbitrary precision\n\n https://github.com/telegraphic/hickle/issues/113'
i = ((2 ** 65) - 1)
dump(i, test_file_name, **compression_kwargs)
i_hkl = load(test_file_name)
assert (i == i_hkl)
j = ((- (2 ** 63)) - 1)
dump(j, test_file_name, **compression_kwargs)
j_hkl = load(test_file_name)
assert (j == j_hkl)
|
def test_65bit_int(test_file_name, compression_kwargs):
' Dumping and loading an integer with arbitrary precision\n\n https://github.com/telegraphic/hickle/issues/113'
i = ((2 ** 65) - 1)
dump(i, test_file_name, **compression_kwargs)
i_hkl = load(test_file_name)
assert (i == i_hkl)
j = ((- (2 ** 63)) - 1)
dump(j, test_file_name, **compression_kwargs)
j_hkl = load(test_file_name)
assert (j == j_hkl)<|docstring|>Dumping and loading an integer with arbitrary precision
https://github.com/telegraphic/hickle/issues/113<|endoftext|>
|
f60642048c3b6e687c00d3495db0d19f303d6e7daa0ab5c91252d185ced44e25
|
def test_list(test_file_name, compression_kwargs):
' Dumping and loading a list '
(filename, mode) = ('test_list.h5', 'w')
list_obj = [1, 2, 3, 4, 5]
dump(list_obj, test_file_name, mode=mode, **compression_kwargs)
list_hkl = load(test_file_name)
try:
assert isinstance(list_hkl, list)
assert (list_obj == list_hkl)
import h5py
a = h5py.File(test_file_name, 'r')
a.close()
except AssertionError:
print('ERR:', list_obj, list_hkl)
import h5py
raise
|
Dumping and loading a list
|
hickle/tests/test_hickle.py
|
test_list
|
texadactyl/hickle
| 0
|
python
|
def test_list(test_file_name, compression_kwargs):
' '
(filename, mode) = ('test_list.h5', 'w')
list_obj = [1, 2, 3, 4, 5]
dump(list_obj, test_file_name, mode=mode, **compression_kwargs)
list_hkl = load(test_file_name)
try:
assert isinstance(list_hkl, list)
assert (list_obj == list_hkl)
import h5py
a = h5py.File(test_file_name, 'r')
a.close()
except AssertionError:
print('ERR:', list_obj, list_hkl)
import h5py
raise
|
def test_list(test_file_name, compression_kwargs):
' '
(filename, mode) = ('test_list.h5', 'w')
list_obj = [1, 2, 3, 4, 5]
dump(list_obj, test_file_name, mode=mode, **compression_kwargs)
list_hkl = load(test_file_name)
try:
assert isinstance(list_hkl, list)
assert (list_obj == list_hkl)
import h5py
a = h5py.File(test_file_name, 'r')
a.close()
except AssertionError:
print('ERR:', list_obj, list_hkl)
import h5py
raise<|docstring|>Dumping and loading a list<|endoftext|>
|
6550dce75d2c35b08394f0a435575caafd42aa785feae73baf030940f21e8422
|
def test_set(test_file_name, compression_kwargs):
' Dumping and loading a list '
mode = 'w'
list_obj = set([1, 0, 3, 4.5, 11.2])
dump(list_obj, test_file_name, mode, **compression_kwargs)
list_hkl = load(test_file_name)
try:
assert isinstance(list_hkl, set)
assert (list_obj == list_hkl)
except AssertionError:
print(type(list_obj))
print(type(list_hkl))
raise
|
Dumping and loading a list
|
hickle/tests/test_hickle.py
|
test_set
|
texadactyl/hickle
| 0
|
python
|
def test_set(test_file_name, compression_kwargs):
' '
mode = 'w'
list_obj = set([1, 0, 3, 4.5, 11.2])
dump(list_obj, test_file_name, mode, **compression_kwargs)
list_hkl = load(test_file_name)
try:
assert isinstance(list_hkl, set)
assert (list_obj == list_hkl)
except AssertionError:
print(type(list_obj))
print(type(list_hkl))
raise
|
def test_set(test_file_name, compression_kwargs):
' '
mode = 'w'
list_obj = set([1, 0, 3, 4.5, 11.2])
dump(list_obj, test_file_name, mode, **compression_kwargs)
list_hkl = load(test_file_name)
try:
assert isinstance(list_hkl, set)
assert (list_obj == list_hkl)
except AssertionError:
print(type(list_obj))
print(type(list_hkl))
raise<|docstring|>Dumping and loading a list<|endoftext|>
|
d3ebcd8e6bce3be9bbf20cf868740c735e51eb9901f0751dbaffe390f5da6a4a
|
def test_numpy(test_file_name, compression_kwargs):
' Dumping and loading numpy array '
mode = 'w'
dtypes = ['float32', 'float64', 'complex64', 'complex128']
for dt in dtypes:
array_obj = np.ones(8, dtype=dt)
dump(array_obj, test_file_name, mode, **compression_kwargs)
array_hkl = load(test_file_name)
try:
assert (array_hkl.dtype == array_obj.dtype)
assert np.all((array_hkl, array_obj))
except AssertionError:
print(array_hkl)
print(array_obj)
raise
|
Dumping and loading numpy array
|
hickle/tests/test_hickle.py
|
test_numpy
|
texadactyl/hickle
| 0
|
python
|
def test_numpy(test_file_name, compression_kwargs):
' '
mode = 'w'
dtypes = ['float32', 'float64', 'complex64', 'complex128']
for dt in dtypes:
array_obj = np.ones(8, dtype=dt)
dump(array_obj, test_file_name, mode, **compression_kwargs)
array_hkl = load(test_file_name)
try:
assert (array_hkl.dtype == array_obj.dtype)
assert np.all((array_hkl, array_obj))
except AssertionError:
print(array_hkl)
print(array_obj)
raise
|
def test_numpy(test_file_name, compression_kwargs):
' '
mode = 'w'
dtypes = ['float32', 'float64', 'complex64', 'complex128']
for dt in dtypes:
array_obj = np.ones(8, dtype=dt)
dump(array_obj, test_file_name, mode, **compression_kwargs)
array_hkl = load(test_file_name)
try:
assert (array_hkl.dtype == array_obj.dtype)
assert np.all((array_hkl, array_obj))
except AssertionError:
print(array_hkl)
print(array_obj)
raise<|docstring|>Dumping and loading numpy array<|endoftext|>
|
282457ddaf4bc1da3442026abf3c36f402380b02a0dc9153cbc5161e2d247702
|
def test_masked(test_file_name, compression_kwargs):
' Test masked numpy array '
mode = 'w'
a = np.ma.array([1, 2, 3, 4], dtype='float32', mask=[0, 1, 0, 0])
dump(a, test_file_name, mode, **compression_kwargs)
a_hkl = load(test_file_name)
try:
assert (a_hkl.dtype == a.dtype)
assert np.all((a_hkl, a))
except AssertionError:
print(a_hkl)
print(a)
raise
|
Test masked numpy array
|
hickle/tests/test_hickle.py
|
test_masked
|
texadactyl/hickle
| 0
|
python
|
def test_masked(test_file_name, compression_kwargs):
' '
mode = 'w'
a = np.ma.array([1, 2, 3, 4], dtype='float32', mask=[0, 1, 0, 0])
dump(a, test_file_name, mode, **compression_kwargs)
a_hkl = load(test_file_name)
try:
assert (a_hkl.dtype == a.dtype)
assert np.all((a_hkl, a))
except AssertionError:
print(a_hkl)
print(a)
raise
|
def test_masked(test_file_name, compression_kwargs):
' '
mode = 'w'
a = np.ma.array([1, 2, 3, 4], dtype='float32', mask=[0, 1, 0, 0])
dump(a, test_file_name, mode, **compression_kwargs)
a_hkl = load(test_file_name)
try:
assert (a_hkl.dtype == a.dtype)
assert np.all((a_hkl, a))
except AssertionError:
print(a_hkl)
print(a)
raise<|docstring|>Test masked numpy array<|endoftext|>
|
168a813051e2eb8e1290f63951ea66a06e5fe5b24fd393fa269c7bdffdcbe9d8
|
def test_object_numpy(test_file_name, compression_kwargs):
' Dumping and loading a NumPy array containing non-NumPy objects.\n\n https://github.com/telegraphic/hickle/issues/90'
arr = np.array([NESTED_DICT])
dump(arr, test_file_name, **compression_kwargs)
arr_hkl = load(test_file_name)
assert np.all((arr == arr_hkl))
arr2 = np.array(NESTED_DICT)
dump(arr2, test_file_name, **compression_kwargs)
arr_hkl2 = load(test_file_name)
assert np.all((arr2 == arr_hkl2))
|
Dumping and loading a NumPy array containing non-NumPy objects.
https://github.com/telegraphic/hickle/issues/90
|
hickle/tests/test_hickle.py
|
test_object_numpy
|
texadactyl/hickle
| 0
|
python
|
def test_object_numpy(test_file_name, compression_kwargs):
' Dumping and loading a NumPy array containing non-NumPy objects.\n\n https://github.com/telegraphic/hickle/issues/90'
arr = np.array([NESTED_DICT])
dump(arr, test_file_name, **compression_kwargs)
arr_hkl = load(test_file_name)
assert np.all((arr == arr_hkl))
arr2 = np.array(NESTED_DICT)
dump(arr2, test_file_name, **compression_kwargs)
arr_hkl2 = load(test_file_name)
assert np.all((arr2 == arr_hkl2))
|
def test_object_numpy(test_file_name, compression_kwargs):
' Dumping and loading a NumPy array containing non-NumPy objects.\n\n https://github.com/telegraphic/hickle/issues/90'
arr = np.array([NESTED_DICT])
dump(arr, test_file_name, **compression_kwargs)
arr_hkl = load(test_file_name)
assert np.all((arr == arr_hkl))
arr2 = np.array(NESTED_DICT)
dump(arr2, test_file_name, **compression_kwargs)
arr_hkl2 = load(test_file_name)
assert np.all((arr2 == arr_hkl2))<|docstring|>Dumping and loading a NumPy array containing non-NumPy objects.
https://github.com/telegraphic/hickle/issues/90<|endoftext|>
|
28a1c85d528620ae269745e7c64b6829a3527e8a4451efd184a927f373f39948
|
def test_string_numpy(test_file_name, compression_kwargs):
' Dumping and loading NumPy arrays containing Python 3 strings. '
arr = np.array(['1313e', 'was', 'maybe?', 'here'])
dump(arr, test_file_name, **compression_kwargs)
arr_hkl = load(test_file_name)
assert np.all((arr == arr_hkl))
|
Dumping and loading NumPy arrays containing Python 3 strings.
|
hickle/tests/test_hickle.py
|
test_string_numpy
|
texadactyl/hickle
| 0
|
python
|
def test_string_numpy(test_file_name, compression_kwargs):
' '
arr = np.array(['1313e', 'was', 'maybe?', 'here'])
dump(arr, test_file_name, **compression_kwargs)
arr_hkl = load(test_file_name)
assert np.all((arr == arr_hkl))
|
def test_string_numpy(test_file_name, compression_kwargs):
' '
arr = np.array(['1313e', 'was', 'maybe?', 'here'])
dump(arr, test_file_name, **compression_kwargs)
arr_hkl = load(test_file_name)
assert np.all((arr == arr_hkl))<|docstring|>Dumping and loading NumPy arrays containing Python 3 strings.<|endoftext|>
|
76cf60e5e728d0d6b61892722d04eb040f7a0165bea26f29313f3085bc6b421a
|
def test_list_object_numpy(test_file_name, compression_kwargs):
' Dumping and loading a list of NumPy arrays with objects.\n\n https://github.com/telegraphic/hickle/issues/90'
lst = [np.array(NESTED_DICT)]
dump(lst, test_file_name, **compression_kwargs)
lst_hkl = load(test_file_name)
assert np.all((lst[0] == lst_hkl[0]))
|
Dumping and loading a list of NumPy arrays with objects.
https://github.com/telegraphic/hickle/issues/90
|
hickle/tests/test_hickle.py
|
test_list_object_numpy
|
texadactyl/hickle
| 0
|
python
|
def test_list_object_numpy(test_file_name, compression_kwargs):
' Dumping and loading a list of NumPy arrays with objects.\n\n https://github.com/telegraphic/hickle/issues/90'
lst = [np.array(NESTED_DICT)]
dump(lst, test_file_name, **compression_kwargs)
lst_hkl = load(test_file_name)
assert np.all((lst[0] == lst_hkl[0]))
|
def test_list_object_numpy(test_file_name, compression_kwargs):
' Dumping and loading a list of NumPy arrays with objects.\n\n https://github.com/telegraphic/hickle/issues/90'
lst = [np.array(NESTED_DICT)]
dump(lst, test_file_name, **compression_kwargs)
lst_hkl = load(test_file_name)
assert np.all((lst[0] == lst_hkl[0]))<|docstring|>Dumping and loading a list of NumPy arrays with objects.
https://github.com/telegraphic/hickle/issues/90<|endoftext|>
|
519070fa2d7eeb39cae0a50c14379007c3ab25beba4d44195a288e58589ec44e
|
def test_dict(test_file_name, compression_kwargs):
' Test dictionary dumping and loading '
mode = 'w'
dd = {'name': b'Danny', 'age': 28, 'height': 6.1, 'dork': True, 'nums': [1, 2, 3], 'narr': np.array([1, 2, 3])}
dump(dd, test_file_name, mode, **compression_kwargs)
dd_hkl = load(test_file_name)
for k in dd.keys():
try:
assert (k in dd_hkl.keys())
if isinstance(dd[k], np.ndarray):
assert np.all((dd[k], dd_hkl[k]))
else:
pass
assert isinstance(dd_hkl[k], dd[k].__class__)
except AssertionError:
print(k)
print(dd_hkl[k])
print(dd[k])
print(type(dd_hkl[k]), type(dd[k]))
raise
|
Test dictionary dumping and loading
|
hickle/tests/test_hickle.py
|
test_dict
|
texadactyl/hickle
| 0
|
python
|
def test_dict(test_file_name, compression_kwargs):
' '
mode = 'w'
dd = {'name': b'Danny', 'age': 28, 'height': 6.1, 'dork': True, 'nums': [1, 2, 3], 'narr': np.array([1, 2, 3])}
dump(dd, test_file_name, mode, **compression_kwargs)
dd_hkl = load(test_file_name)
for k in dd.keys():
try:
assert (k in dd_hkl.keys())
if isinstance(dd[k], np.ndarray):
assert np.all((dd[k], dd_hkl[k]))
else:
pass
assert isinstance(dd_hkl[k], dd[k].__class__)
except AssertionError:
print(k)
print(dd_hkl[k])
print(dd[k])
print(type(dd_hkl[k]), type(dd[k]))
raise
|
def test_dict(test_file_name, compression_kwargs):
' '
mode = 'w'
dd = {'name': b'Danny', 'age': 28, 'height': 6.1, 'dork': True, 'nums': [1, 2, 3], 'narr': np.array([1, 2, 3])}
dump(dd, test_file_name, mode, **compression_kwargs)
dd_hkl = load(test_file_name)
for k in dd.keys():
try:
assert (k in dd_hkl.keys())
if isinstance(dd[k], np.ndarray):
assert np.all((dd[k], dd_hkl[k]))
else:
pass
assert isinstance(dd_hkl[k], dd[k].__class__)
except AssertionError:
print(k)
print(dd_hkl[k])
print(dd[k])
print(type(dd_hkl[k]), type(dd[k]))
raise<|docstring|>Test dictionary dumping and loading<|endoftext|>
|
fc5df67e20c5f725209810f0c4f1b1e8fd094d772aa0502d2358cc180b9ac357
|
def test_odict(test_file_name, compression_kwargs):
' Test ordered dictionary dumping and loading\n\n https://github.com/telegraphic/hickle/issues/65'
mode = 'w'
od = odict(((3, [3, 0.1]), (7, [5, 0.1]), (5, [3, 0.1])))
dump(od, test_file_name, mode, **compression_kwargs)
od_hkl = load(test_file_name)
assert (od.keys() == od_hkl.keys())
for (od_item, od_hkl_item) in zip(od.items(), od_hkl.items()):
assert (od_item == od_hkl_item)
|
Test ordered dictionary dumping and loading
https://github.com/telegraphic/hickle/issues/65
|
hickle/tests/test_hickle.py
|
test_odict
|
texadactyl/hickle
| 0
|
python
|
def test_odict(test_file_name, compression_kwargs):
' Test ordered dictionary dumping and loading\n\n https://github.com/telegraphic/hickle/issues/65'
mode = 'w'
od = odict(((3, [3, 0.1]), (7, [5, 0.1]), (5, [3, 0.1])))
dump(od, test_file_name, mode, **compression_kwargs)
od_hkl = load(test_file_name)
assert (od.keys() == od_hkl.keys())
for (od_item, od_hkl_item) in zip(od.items(), od_hkl.items()):
assert (od_item == od_hkl_item)
|
def test_odict(test_file_name, compression_kwargs):
' Test ordered dictionary dumping and loading\n\n https://github.com/telegraphic/hickle/issues/65'
mode = 'w'
od = odict(((3, [3, 0.1]), (7, [5, 0.1]), (5, [3, 0.1])))
dump(od, test_file_name, mode, **compression_kwargs)
od_hkl = load(test_file_name)
assert (od.keys() == od_hkl.keys())
for (od_item, od_hkl_item) in zip(od.items(), od_hkl.items()):
assert (od_item == od_hkl_item)<|docstring|>Test ordered dictionary dumping and loading
https://github.com/telegraphic/hickle/issues/65<|endoftext|>
|
4e45dd2a48e891706f522f4132de91b2a977ff0436c50f58abc302a57527b8f2
|
def test_empty_dict(test_file_name, compression_kwargs):
' Test empty dictionary dumping and loading\n\n https://github.com/telegraphic/hickle/issues/91'
mode = 'w'
dump({}, test_file_name, mode, **compression_kwargs)
assert (load(test_file_name) == {})
|
Test empty dictionary dumping and loading
https://github.com/telegraphic/hickle/issues/91
|
hickle/tests/test_hickle.py
|
test_empty_dict
|
texadactyl/hickle
| 0
|
python
|
def test_empty_dict(test_file_name, compression_kwargs):
' Test empty dictionary dumping and loading\n\n https://github.com/telegraphic/hickle/issues/91'
mode = 'w'
dump({}, test_file_name, mode, **compression_kwargs)
assert (load(test_file_name) == {})
|
def test_empty_dict(test_file_name, compression_kwargs):
' Test empty dictionary dumping and loading\n\n https://github.com/telegraphic/hickle/issues/91'
mode = 'w'
dump({}, test_file_name, mode, **compression_kwargs)
assert (load(test_file_name) == {})<|docstring|>Test empty dictionary dumping and loading
https://github.com/telegraphic/hickle/issues/91<|endoftext|>
|
f939b89aa571146289bec179d57758452108c1dd2d309a2621a861849e270e83
|
@pytest.mark.no_compression
def test_compression(test_file_name):
' Test compression on datasets'
mode = 'w'
dtypes = ['int32', 'float32', 'float64', 'complex64', 'complex128']
comps = [None, 'gzip', 'lzf']
for dt in dtypes:
for cc in comps:
array_obj = np.ones(32768, dtype=dt)
dump(array_obj, test_file_name, mode, compression=cc)
print(cc, os.path.getsize(test_file_name))
array_hkl = load(test_file_name)
try:
assert (array_hkl.dtype == array_obj.dtype)
assert np.all((array_hkl, array_obj))
except AssertionError:
print(array_hkl)
print(array_obj)
raise
|
Test compression on datasets
|
hickle/tests/test_hickle.py
|
test_compression
|
texadactyl/hickle
| 0
|
python
|
@pytest.mark.no_compression
def test_compression(test_file_name):
' '
mode = 'w'
dtypes = ['int32', 'float32', 'float64', 'complex64', 'complex128']
comps = [None, 'gzip', 'lzf']
for dt in dtypes:
for cc in comps:
array_obj = np.ones(32768, dtype=dt)
dump(array_obj, test_file_name, mode, compression=cc)
print(cc, os.path.getsize(test_file_name))
array_hkl = load(test_file_name)
try:
assert (array_hkl.dtype == array_obj.dtype)
assert np.all((array_hkl, array_obj))
except AssertionError:
print(array_hkl)
print(array_obj)
raise
|
@pytest.mark.no_compression
def test_compression(test_file_name):
' '
mode = 'w'
dtypes = ['int32', 'float32', 'float64', 'complex64', 'complex128']
comps = [None, 'gzip', 'lzf']
for dt in dtypes:
for cc in comps:
array_obj = np.ones(32768, dtype=dt)
dump(array_obj, test_file_name, mode, compression=cc)
print(cc, os.path.getsize(test_file_name))
array_hkl = load(test_file_name)
try:
assert (array_hkl.dtype == array_obj.dtype)
assert np.all((array_hkl, array_obj))
except AssertionError:
print(array_hkl)
print(array_obj)
raise<|docstring|>Test compression on datasets<|endoftext|>
|
cbdd3ec12c75d63a61ea6dcc0c19f6d279336a44dc2c73843c813ca859eac180
|
def test_dict_int_key(test_file_name, compression_kwargs):
' Test for dictionaries with integer keys '
mode = 'w'
dd = {0: 'test', 1: 'test2'}
dump(dd, test_file_name, mode, **compression_kwargs)
load(test_file_name)
|
Test for dictionaries with integer keys
|
hickle/tests/test_hickle.py
|
test_dict_int_key
|
texadactyl/hickle
| 0
|
python
|
def test_dict_int_key(test_file_name, compression_kwargs):
' '
mode = 'w'
dd = {0: 'test', 1: 'test2'}
dump(dd, test_file_name, mode, **compression_kwargs)
load(test_file_name)
|
def test_dict_int_key(test_file_name, compression_kwargs):
' '
mode = 'w'
dd = {0: 'test', 1: 'test2'}
dump(dd, test_file_name, mode, **compression_kwargs)
load(test_file_name)<|docstring|>Test for dictionaries with integer keys<|endoftext|>
|
6062900fc5fa1acb35e63971a0ac5e55411cd43e5dbf22d4ddf8787801f9cab7
|
def test_dict_nested(test_file_name, compression_kwargs):
' Test for dictionaries with integer keys '
mode = 'w'
dd = NESTED_DICT
dump(dd, test_file_name, mode, **compression_kwargs)
dd_hkl = load(test_file_name)
ll_hkl = dd_hkl['level1_3']['level2_1']['level3_1']
ll = dd['level1_3']['level2_1']['level3_1']
assert (ll == ll_hkl)
|
Test for dictionaries with integer keys
|
hickle/tests/test_hickle.py
|
test_dict_nested
|
texadactyl/hickle
| 0
|
python
|
def test_dict_nested(test_file_name, compression_kwargs):
' '
mode = 'w'
dd = NESTED_DICT
dump(dd, test_file_name, mode, **compression_kwargs)
dd_hkl = load(test_file_name)
ll_hkl = dd_hkl['level1_3']['level2_1']['level3_1']
ll = dd['level1_3']['level2_1']['level3_1']
assert (ll == ll_hkl)
|
def test_dict_nested(test_file_name, compression_kwargs):
' '
mode = 'w'
dd = NESTED_DICT
dump(dd, test_file_name, mode, **compression_kwargs)
dd_hkl = load(test_file_name)
ll_hkl = dd_hkl['level1_3']['level2_1']['level3_1']
ll = dd['level1_3']['level2_1']['level3_1']
assert (ll == ll_hkl)<|docstring|>Test for dictionaries with integer keys<|endoftext|>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.