Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Commit

Permalink
Suppress unused variable warnings in test_namespaces.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
mwchase committed Jul 16, 2017
1 parent b449ce3 commit f0d7a2b
Showing 1 changed file with 44 additions and 21 deletions.
65 changes: 44 additions & 21 deletions tests/test_namespaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def test_finalization(namespaceable, namespace):
"""Test error messages around finalization."""
scopes = []

class Test(namespaceable):
# Class only exists to test scope finalization.
class Test(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing scope finalization."""
with namespace() as namespace_:
with pytest.raises(ValueError,
Expand Down Expand Up @@ -49,27 +50,31 @@ def test_basic_scope_len(namespaceable, namespace):
"""Test the overall length behavior of scopes, with various layouts."""
scopes = {}

class Test1(namespaceable):
# Class only exists to extract a scope from it.
class Test1(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing scope length."""
with namespace() as namespace_:
scopes[1] = get_ns(namespace_).scope

class Test2(namespaceable):
# Class only exists to extract a scope from it.
class Test2(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing scope length."""
with namespace() as namespace_1:
scopes[2] = get_ns(namespace_1).scope
with namespace() as namespace_2:
pass

class Test3(namespaceable):
# Class only exists to extract a scope from it.
class Test3(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing scope length."""
with namespace() as namespace_1:
footer = 1
scopes[3] = get_ns(namespace_1).scope
with namespace() as namespace_2:
pass

class Test4(namespaceable):
# Class only exists to extract a scope from it.
class Test4(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing scope length."""
with namespace() as namespace_1:
with namespace() as namespace_:
Expand All @@ -96,27 +101,31 @@ def test_basic_scope_iter(namespaceable, namespace):
"""Test the overall iteration behavior of scopes, with various layouts."""
scopes = {}

class Test1(namespaceable):
# Class only exists to extract a scope from it.
class Test1(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing scope iteration."""
with namespace() as namespace_:
scopes[1] = get_ns(namespace_).scope

class Test2(namespaceable):
# Class only exists to extract a scope from it.
class Test2(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing scope iteration."""
with namespace() as namespace_1:
scopes[2] = get_ns(namespace_1).scope
with namespace() as namespace_2:
pass

class Test3(namespaceable):
# Class only exists to extract a scope from it.
class Test3(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing scope iteration."""
with namespace() as namespace_1:
footer = 1
scopes[3] = get_ns(namespace_1).scope
with namespace() as namespace_2:
pass

class Test4(namespaceable):
# Class only exists to extract a scope from it.
class Test4(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing scope iteration."""
with namespace() as namespace_1:
with namespace() as namespace_:
Expand Down Expand Up @@ -145,7 +154,8 @@ def test_scope_nsd_get(namespaceable, namespace):
"""Test scope get with nesting."""
scopes = {}

class Test(namespaceable):
# Class only exists to extract a scope from it.
class Test(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing scope indexing."""
with namespace() as namespace_:
with namespace() as namespace_:
Expand Down Expand Up @@ -191,7 +201,8 @@ def test_scope_nsd_get_error(namespaceable, namespace):
"""Test getting a nonexistent member of a nested scope."""
scopes = {}

class Test(namespaceable):
# Class only exists to extract a scope from it.
class Test(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing failing scope get."""
with namespace() as namespace_:
with namespace() as namespace_:
Expand All @@ -208,7 +219,8 @@ def test_scope_nsd_get_non_ns(namespaceable, namespace):
"""Test a nested get that goes too deep."""
scopes = {}

class Test(namespaceable):
# Class only exists to extract a scope from it.
class Test(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing over-deep scope get."""
with namespace() as namespace_:
with namespace() as namespace_:
Expand All @@ -226,7 +238,8 @@ def test_scope_nsd_get_non_existent(namespaceable, namespace):
"""Test a nested get that's missing the first level of nesting."""
scopes = {}

class Test(namespaceable):
# Class only exists to extract a scope from it.
class Test(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing failing scope get."""
with namespace() as namespace_:
with namespace() as namespace_:
Expand All @@ -243,7 +256,8 @@ def test_scope_nsd_get_non_recursive(namespaceable, namespace):
"""Test a non-recursive scope get."""
scopes = {}

class Test(namespaceable):
# Class only exists to extract a scope from it.
class Test(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing basic scope get."""
with namespace() as namespace_:
with namespace() as namespace_:
Expand Down Expand Up @@ -277,7 +291,8 @@ class Test(namespaceable):

def test_empty_nameless(namespaceable, namespace):
"""Test an unnamed namespace with nothing in it."""
class Test(namespaceable):
# Class only exists to confirm namespaces must be named.
class Test(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing nameless namespace."""
with pytest.raises(RuntimeError, message='Namespace must be named.'):
with namespace():
Expand All @@ -286,7 +301,8 @@ class Test(namespaceable):

def test_non_empty_nameless(namespaceable, namespace):
"""Test an unnamed namespace with something in it."""
class Test(namespaceable):
# Class only exists to confirm namespaces must be named.
class Test(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing nameless namespace."""
with pytest.raises(RuntimeError, message='Namespace must be named.'):
with namespace():
Expand All @@ -295,7 +311,8 @@ class Test(namespaceable):

def test_rename(namespaceable, namespace):
"""Test renaming a namespace."""
class Test(namespaceable):
# Class only exists to confirm rename fails.
class Test(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing namespace rename."""
with namespace() as namespace_:
pass
Expand Down Expand Up @@ -330,7 +347,10 @@ class Test(namespaceable):
def test_dont_need_to_inherit(
namespaceable): # pylint: disable=unused-argument
"""Test using the metaclass without the convenience class."""
class Test(metaclass=type(namespaceable)):
metaclass = type(namespaceable)

# Class only exists to confirm the metaclass works.
class Test(metaclass=metaclass): # pylint: disable=unused-variable
"""Throwaway test class, for testing the metaclass."""


Expand Down Expand Up @@ -405,7 +425,8 @@ def test_can_t_get_path(namespace):

def test_non_existent_attribute_during_creation(namespaceable, namespace):
"""Test that looking for a non-existent attribute raises AttributeError."""
class Test(namespaceable):
# Class only exists to confirm get fails.
class Test(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing nonexistent attribute get."""
with namespace() as namespace_:
pass
Expand Down Expand Up @@ -466,7 +487,8 @@ def test_namespace_is_truthy(namespace):

def test_bad_del_in_definition(namespaceable, namespace):
"""Test that deletes of nonexistent attributes still raise NameError."""
class Test(namespaceable):
# Class only exists to confirm delete fails.
class Test(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing failing delete."""
with namespace() as namespace_:
with pytest.raises(
Expand All @@ -477,7 +499,8 @@ class Test(namespaceable):
# Not 100% sure this is desired behavior. See Issue 12.
def test_subtle_bad_del_in_definition(namespaceable, namespace):
"""Test that deletes of nonexistent attributes still raise NameError."""
class Test(namespaceable):
# Class only exists to confirm delete fails.
class Test(namespaceable): # pylint: disable=unused-variable
"""Throwaway test class, for testing failing delete."""
footer = 1
with namespace() as namespace_:
Expand Down

0 comments on commit f0d7a2b

Please sign in to comment.