Commits

Alex Grönholm committed 85a4fdd

PEP 8 fixes

Comments (0)

Files changed (20)

+[pep8]
+ignore=E501
+exclude=.tox,runtests.py,bootstrap.py,conf.py

fanstatic/__init__.py

                             clear_needed,
                             register_inclusion_renderer,
                             UnknownResourceExtensionError,
-                            UnknownResourceExtension, # BBB
+                            UnknownResourceExtension,  # BBB
                             LibraryDependencyCycleError,
                             ConfigurationError,
                             SlotError,
                             set_resource_file_existence_checking,
                             UnknownResourceError)
-
 from fanstatic.registry import get_library_registry, LibraryRegistry
-
 from fanstatic.codegen import generate_code
-
 from fanstatic.injector import Injector, make_injector
-
 from fanstatic.publisher import (Publisher, Delegator, make_publisher,
                                  LibraryPublisher)
-
 from fanstatic.wsgi import Fanstatic, make_fanstatic, Serf, make_serf

fanstatic/checksum.py

+from datetime import datetime
 import os
 import hashlib
-from datetime import datetime
 
 from fanstatic import compat
 
         latest = max(mtime, latest)
     return datetime.fromtimestamp(latest).isoformat()[:22]
 
+
 def md5(path):
     chcksm = hashlib.md5()
     for path in sorted(list(list_directory(path, include_directories=False))):

fanstatic/config.py

                    'bottom', 'force_bottom', 'bundle', 'rollup',
                    'versioning_use_md5'])
 
+
 # From paste.util.converters.
 def asbool(obj):
     if isinstance(obj, compat.basestring):
                 "String is not true/false: %r" % obj)
     return bool(obj)
 
+
 def convert_config(config):
     result = {}
     for key, value in compat.iteritems(config):

fanstatic/core.py

 
 _resource_file_existence_checking = True
 
+
 def set_resource_file_existence_checking(v):
     """Set resource file existence checking to True or False.
 
     global _resource_file_existence_checking
     _resource_file_existence_checking = v
 
+
 class UnknownResourceExtensionError(Exception):
     """A resource has an unrecognized extension.
     """
 
+
 class ModeResourceDependencyError(Exception):
     """A Mode Resource does not have the same dependencies as the
     resource it replaces.
 # BBB backwards compatibility
 UnknownResourceExtension = UnknownResourceExtensionError
 
+
 class UnknownResourceError(Exception):
     """Resource refers to non-existent resource file.
     """
 
+
 class ConfigurationError(Exception):
     """Impossible or illegal configuration.
     """
 
+
 class LibraryDependencyCycleError(Exception):
     """Dependency cycles between libraries aren't allowed.
 
     depends on a file in the first library.
     """
 
+
 class SlotError(Exception):
     """A slot was filled in incorrectly.
 
     If this is not the case, it is an error.
     """
 
+
 class Library(object):
     """The resource library.
 
                 mode.supersedes.append(superseded_mode)
                 superseded_mode.rollups.append(mode)
 
-
         # Register ourself with the Library.
         self.library.register(self)
 
         needed = get_needed()
         needed.need(self, slots)
 
+
 # XXX have to lie here: a slot itself is not directly renderable,
 # that's a FilledSlot.
 class Slot(Renderable, Dependable):
                                 dependency_nr)
         self.dependency_nr = dependency_nr
 
+
 class FilledSlot(Renderable, Dependable):
     def __init__(self, slot, resource):
         self.library = resource.library
             # fall back on the default mode if mode not found
             return self
 
+
 class Group(Dependable):
     """A resource used to group resources together.
 
         return False
 
     def _not_implented_here(self, *args, **kwargs):
-        raise NotImplementedError('''
+        raise NotImplementedError(
+            '''
             This functionality is not implemented by objects of the %s class.
-            You probably want a NeededResources object.'''\
-            % self.__class__.__name__)
+            You probably want a NeededResources object.''' %
+            self.__class__.__name__)
 
     clear = _not_implented_here
     library_url = render = render_inclusions = _not_implented_here
             result.append(resource)
     return result
 
+
 def sort_resources(resources):
     """Sort resources for inclusion on web page.
 

fanstatic/injector.py

 
 CONTENT_TYPES = ['text/html', 'text/xml', 'application/xhtml+xml']
 
+
 class Injector(object):
     """Fanstatic injector WSGI framework component.
 

fanstatic/publisher.py

 import time
-import os
 import os.path
 import fnmatch
-import webob
+
 import webob.dec
 import webob.exc
 import webob.static
+
 import fanstatic
 
 MINUTE_IN_SECONDS = 60
         app = self.cached_apps.get(req.path)
         if app is None:
             path = os.path.abspath(
-                    os.path.join(self.path, req.path_info.lstrip('/')))
+                os.path.join(self.path, req.path_info.lstrip('/')))
             if not path.startswith(self.path):
                 raise webob.exc.HTTPForbidden()
             elif fanstatic.BUNDLE_PREFIX in path:
         # pop version if it's there
         potential_version = request.path_info_peek()
         if potential_version is not None and \
-            potential_version.startswith(fanstatic.VERSION_PREFIX):
+                potential_version.startswith(fanstatic.VERSION_PREFIX):
             request.path_info_pop()
             need_caching = True
         else:

fanstatic/wsgi.py

 import webob
+
 from fanstatic.config import convert_config
-import fanstatic
 from fanstatic import (Injector, Delegator, Publisher, get_library_registry,
                        ConfigurationError)
+import fanstatic
+
 
 def Fanstatic(app,
               publisher_signature=fanstatic.DEFAULT_SIGNATURE,
     local_config = convert_config(local_config)
     return Fanstatic(app, **local_config)
 
+
 class Serf(object):
     """Serf WSGI application.
 
     Serve a very simple HTML page while needing a resource. Can be
     configured behind the :py:func:`Fanstatic` WSGI framework
     component to let the resource be included.
-    
+
     :param resource: The :py:class:`Resource` to include.
     """
 
         """
         self.resource.need()
         return webob.Response('<html><head></head><body></body></html>')
-    
+
+
 def make_serf(global_config, **local_config):
     resource_identifier = local_config['resource']
     # only accept 'py:' library identifiers at this point
         raise ConfigurationError("Unknown library identifier")
     return Serf(resource)
 
+
 # taken from zope.dottedname.resolve
 def resolve(name, module=None):
     name = name.split('.')
     + '\n' +
     open('CHANGES.txt').read())
 
+
 class PyTest(Command):
     user_options = []
+
     def initialize_options(self):
         pass
+
     def finalize_options(self):
         pass
+
     def run(self):
-        import sys,subprocess
+        import sys
+        import subprocess
         errno = subprocess.call([sys.executable, 'runtests.py'])
         raise SystemExit(errno)
 
     tests_require=[
         'pytest >= 2.0'
     ],
-    cmdclass = {'test': PyTest},
-    entry_points = {
+    cmdclass={'test': PyTest},
+    entry_points={
         'paste.filter_app_factory': [
             'fanstatic = fanstatic:make_fanstatic',
             'publisher = fanstatic:make_publisher',
             'injector = fanstatic:make_injector',
-            ],
+        ],
         'paste.app_factory': [
             'serf = fanstatic:make_serf',
-            ],
+        ],
     })

tests/conftest.py

 from fanstatic import set_resource_file_existence_checking
 
+
 def pytest_runtest_setup(item):
     set_resource_file_existence_checking(False)
 
+
 def pytest_runtest_teardown(item):
     set_resource_file_existence_checking(True)
-    
-    

tests/test_bundle.py

 
 from fanstatic.core import bundle_resources, Bundle
 
+
 def test_bundle_resources():
     foo = Library('foo', '')
     x1 = Resource(foo, 'a.css')
     needed = NeededResources(resources=[x1, x2, x4, x5], bundle=True)
     assert needed.render() == '''<link rel="stylesheet" type="text/css" href="/fanstatic/foo/:bundle:a.css;b.css" />
 <link rel="stylesheet" type="text/css" href="/fanstatic/foo/subdir/subdir/:bundle:x4.css;x5.css" />'''
-

tests/test_checksum.py

 import time
 import shutil
 import os
+
 from pkg_resources import resource_filename
 
 from fanstatic.checksum import list_directory, md5, mtime
         tmpdir.join('MyPackage/MANIFEST.in').strpath,
         tmpdir.join('MyPackage/src/mypackage/__init__.py').strpath,
         tmpdir.join('MyPackage/src/mypackage/resources/style.css').strpath,
-        ]
+    ]
     found = list(list_directory(testdata_path, include_directories=False))
     assert sorted(found) == sorted(expected)
 
         tmpdir.join('MyPackage/src/mypackage/__init__.py').strpath,
         tmpdir.join('MyPackage/src/mypackage/resources').strpath,
         tmpdir.join('MyPackage/src/mypackage/resources/style.css').strpath,
-        ]
+    ]
     found = list(list_directory(testdata_path))
     assert sorted(found) == sorted(expected)
 
             tmpdir.join('MyPackage/src/mypackage/__init__.py').strpath,
             tmpdir.join('MyPackage/src/mypackage/resources').strpath,
             tmpdir.join('MyPackage/src/mypackage/resources/style.css').strpath,
-            ]
+        ]
         found = list(list_directory(testdata_path))
         assert sorted(found) == sorted(expected)
         tmpdir.join('/MyPackage/%s' % name).remove(rec=True)
         tmpdir.join('MyPackage/src/mypackage/__init__.py').strpath,
         tmpdir.join('MyPackage/src/mypackage/resources').strpath,
         tmpdir.join('MyPackage/src/mypackage/resources/style.css').strpath,
-        ]
+    ]
     found = list(list_directory(testdata_path))
     assert sorted(found) == sorted(expected)
 
             tmpdir.join('MyPackage/src/mypackage/__init__.py').strpath,
             tmpdir.join('MyPackage/src/mypackage/resources').strpath,
             tmpdir.join('MyPackage/src/mypackage/resources/style.css').strpath,
-            ]
+        ]
         found = list(list_directory(testdata_path))
         assert sorted(found) == sorted(expected)
 
     assert mtime_after_add != mtime_start
 
     # Remove the file again, the mtime changed:
-    time.sleep(sleep) 
+    time.sleep(sleep)
     tmpdir.join('/MyPackage/A').remove()
     mtime_after_remove = mtime(testdata_path)
     assert mtime_after_remove != mtime_after_add
         tmpdir.join('MyPackage/src/mypackage/__init__.py').strpath,
         tmpdir.join('MyPackage/src/mypackage/resources').strpath,
         tmpdir.join('MyPackage/src/mypackage/resources/style.css').strpath,
-        ]
+    ]
     found = list(list_directory(testdata_path))
     assert sorted(found) == sorted(expected)
     assert mtime(testdata_path) != mtime_start
         tmpdir.join('MyPackage/src/mypackage/__init__.py').strpath,
         tmpdir.join('MyPackage/src/mypackage/resources').strpath,
         tmpdir.join('MyPackage/src/mypackage/resources/style.css').strpath,
-        ]
+    ]
     found = list(list_directory(testdata_path))
     assert sorted(found) == sorted(expected)
     assert md5(testdata_path) != md5_start
-

tests/test_codegen.py

     j1 = Resource(foo, 'j1.js', debug='j1-debug.js')
     j2 = Resource(foo, 'j2.js', debug='j2-debug.js')
     giantj = Resource(foo, 'giantj.js', supersedes=[j1, j2],
-                               debug='giantj-debug.js')
+                      debug='giantj-debug.js')
     non_inlinable = Resource(foo, 'j3.js', debug=Resource(bar,
                                                           'j4.js'))
     generated = generate_code(j1=j1, j2=j2, giantj=giantj,

tests/test_config.py

         'force_bottom': 'False',
         'rollup': 0,
         'somethingelse': 'True',
-        }
+    }
     assert convert_config(d) == {
         'versioning': True,
         'recompute_hashes': False,
         'force_bottom': False,
         'rollup': False,
         'somethingelse': 'True',
-        }
+    }
 
 
 def test_injector_config():
         'bottom': 'True',
         'force_bottom': 'False',
         'rollup': 0,
-        }
+    }
     injector = make_injector(None, {}, **d)
     assert injector.app is None
     assert injector.config == {
         'bottom': True,
         'force_bottom': False,
         'rollup': False,
-        }
+    }
 
 
 def test_publisher_config():
-    publisher = make_publisher(None,  {}, publisher_signature='foo')
+    publisher = make_publisher(None, {}, publisher_signature='foo')
     assert publisher.trigger == '/foo/'
     assert publisher.app is None
 
         'force_bottom': 'False',
         'rollup': 0,
         'publisher_signature': 'foo',
-        }
+    }
     fanstatic = make_fanstatic(None, {}, **d)
     assert fanstatic.trigger == '/foo/'
     assert fanstatic.app.config == {
         'force_bottom': False,
         'rollup': False,
         'publisher_signature': 'foo',
-        }
+    }

tests/test_core.py

 import os
 import re
+import time
+
 import pytest
-import time
 
 from fanstatic import (Library,
                        Resource,
                        UnknownResourceExtensionError,
                        UnknownResourceError,
                        set_resource_file_existence_checking, compat)
-
 from fanstatic.core import inclusion_renderers
 from fanstatic.core import thread_local_needed_data
 from fanstatic.core import ModeResourceDependencyError
 from fanstatic.codegen import sort_resources_topological
 
+
 def test_resource():
     foo = Library('foo', '')
     x1 = Resource(foo, 'a.js')
 
     assert needed.resources() == [x2, x1, y1]
 
+
 def test_resource_file_exists(tmpdir):
     tmpdir.join('a.js').write('/* hello world */')
     # by default this is set to False during the tests, but in normal
     sub_c = tmpdir.mkdir('sub').join('c.css').write('c')
     c = Resource(foo, 'sub/c.css')
 
+
 def test_resource_register_with_library():
     foo = Library('foo', '')
     x1 = Resource(foo, 'a.js', minified='a.min.js')
     with pytest.raises(NotImplementedError):
         clear_needed()
 
+
 def test_convenience_need():
     foo = Library('foo', '')
     x1 = Resource(foo, 'a.js')
 
     assert get_needed().resources() == [x2, x1, y1]
 
+
 def test_depend_on_group():
     foo = Library('foo', '')
     a = Resource(foo, 'a.js')
     needed.need(c)
     assert needed.resources() == [a, b, c]
 
+
 def test_redundant_resource():
     foo = Library('foo', '')
     x1 = Resource(foo, 'a.js')
 
 
 def test_mode_shortcut_inherit_parameters():
-    foo = Library('foo', '')
     def special_renderer(url):
         return '<special href="%s"/>' % url
+
+    foo = Library('foo', '')
     a = Resource(foo, 'a.js')
     k = Resource(
         foo, 'k.js', debug='k-debug.js',
     debug_resource = k.modes['debug']
     assert debug_resource.depends == k.depends
     assert debug_resource.renderer == special_renderer
-    assert debug_resource.dont_bundle == True
+    assert debug_resource.dont_bundle
 
 
 def test_mode_inherit_dependency_nr():
     assert (needed.library_url(foo) ==
             'http://example.com/something/fanstatic/foo')
 
+
 def test_library_url_script_name():
     foo = Library('foo', '')
     needed = NeededResources(script_name='/root')
     assert needed.library_url(foo) == '/root/fanstatic/foo'
 
+
 def test_library_url_script_name_base_url():
     foo = Library('foo', '')
     needed = NeededResources(
     assert (needed.library_url(foo) ==
             'http://example.com/something/fanstatic/foo')
 
+
 def test_library_url_version_hashing(tmpdir):
     foo = Library('foo', tmpdir.strpath)
 
     <script type="text/javascript" src="/fanstatic/foo/a.js"></script>
 something</head></html>'''
 
+
 def test_html_top_bottom():
     foo = Library('foo', '')
     x1 = Resource(foo, 'a.js')
 <script type="text/javascript" src="/fanstatic/foo/y2.js"></script>
 <script type="text/javascript" src="/fanstatic/foo/c.js"></script>'''
 
+
 # XXX add sanity checks: cannot declare something bottom safe while
 # what it depends on isn't bottom safe
 
     assert bottom == ('<script type="text/javascript" '
                       'src="/fanstatic/foo/a-minified.js"></script>')
 
+
 def test_top_bottom_insert():
     foo = Library('foo', '')
     x1 = Resource(foo, 'a.js')
 
 def test_inclusion_renderers():
     assert sorted(
-        [(order, key) for key, (order, _) in compat.dict_items(inclusion_renderers)]) == [
-        (10, '.css'), (20, '.js'), (30, '.ico')]
+        [(order, key) for key, (order, _) in compat.dict_items(inclusion_renderers)]) == \
+        [(10, '.css'), (20, '.js'), (30, '.ico')]
     _, renderer = inclusion_renderers['.js']
     assert renderer('http://localhost/script.js') == (
-         '<script type="text/javascript" src="http://localhost/script.js"></script>')
+        '<script type="text/javascript" src="http://localhost/script.js"></script>')
 
 
 def test_register_inclusion_renderer():
 
     assert needed.resources() == [b_css, a_js, c_js, a1_js]
 
+
 def test_sort_group_per_library():
     foo = Library('foo', '')
     bar = Library('bar', '')
 
     assert needed.resources() == [e, d, b, c, a]
 
+
 def test_sort_library_by_name():
     b_lib = Library('b_lib', '')
     a_lib = Library('a_lib', '')
 
     assert needed.resources() == [a_a, a_b]
 
+
 def test_sort_resources_libraries_together():
     K = Library('K', '')
     L = Library('L', '')
     # the order is unaffected by the ordering of inclusions
     assert needed.resources() == [k1, l1, m1, m2, n1]
 
+
 def test_sort_resources_library_sorting():
     # a complicated example that makes sure libraries are sorted
     # correctly to obey ordering constraints but still groups them
 
     assert needed.resources() == [a, c, c1, c2, e, b, d]
 
+
 def test_sort_resources_library_sorting_by_name():
     # these libraries are all at the same level so should be sorted by name
     X = Library('X', '')
 
     assert needed.resources() == [a, b, c]
 
+
 def test_sort_resources_library_sorting_by_name_deeper():
     X = Library('X', '')
     Y = Library('Y', '')
     needed.need(b)
     assert needed.resources() == [a, c, b]
 
+
 def test_library_nr():
     X = Library('X', '')
     Y = Library('Y', '')
     assert c.library.library_nr == 0
     assert b.library.library_nr == 1
 
+
 def test_library_dependency_cycles():
     A = Library('A', '')
     B = Library('B', '')
 
     assert sort_resources_topological([a5, a3, a1, a2]) == [a1, a2, a3, a5]
 
+
 def test_bundle():
     foo = Library('foo', '')
     a = Resource(foo, 'a.css')
     bundle = resources[0]
     assert bundle.resources() == [a, b]
 
+
 def test_bundle_dont_bundle_at_the_end():
     foo = Library('foo', '')
     a = Resource(foo, 'a.css')
     assert resources[0].resources() == [a, b]
     assert resources[-1] is c
 
+
 def test_bundle_dont_bundle_at_the_start():
     foo = Library('foo', '')
     a = Resource(foo, 'a.css', dont_bundle=True)
     assert resources[0] is a
     assert resources[1].resources() == [b, c]
 
+
 def test_bundle_dont_bundle_in_the_middle():
     # now construct a scenario where a dont_bundle resource is in the way
     # of bundling
     assert resources[1] is b
     assert resources[2] is c
 
+
 def test_bundle_resources_bottomsafe():
     foo = Library('foo', '')
     a = Resource(foo, 'a.css')
     b = Resource(foo, 'b.css', bottom=True)
 
-    needed = NeededResources(resources=[a,b], bundle=True)
+    needed = NeededResources(resources=[a, b], bundle=True)
     assert needed.render_topbottom() == ('''\
 <link rel="stylesheet" type="text/css" href="/fanstatic/foo/:bundle:a.css;b.css" />''', '')
 
-    needed = NeededResources(resources=[a,b], bundle=True, bottom=True)
+    needed = NeededResources(resources=[a, b], bundle=True, bottom=True)
     assert needed.render_topbottom() == ('''\
 <link rel="stylesheet" type="text/css" href="/fanstatic/foo/a.css" />''', '''\
 <link rel="stylesheet" type="text/css" href="/fanstatic/foo/b.css" />''')
     assert resources[0] is a
     assert resources[1] is b
 
+
 def test_bundle_different_library():
     # resources with different libraries aren't bundled
     l1 = Library('l1', '')
     assert resources[0] is a
     assert resources[1] is b
 
+
 def test_bundle_different_directory():
     # resources with different directories aren't bundled
     foo = Library('foo', '')
     assert resources[0] is a
     assert resources[1] is b
 
+
 def test_bundle_empty_list():
     # we can successfully bundle an empty list of resources
     needed = NeededResources(bundle=True)
     resources = needed.resources()
     assert resources == []
 
+
 def test_bundle_single_entry():
     # we can successfully bundle a single resource (it's not bundled though)
     foo = Library('foo', '')
 
     assert resources == [a]
 
+
 def test_bundle_single_dont_bundle_entry():
     foo = Library('foo', '')
     a = Resource(foo, 'a.js', dont_bundle=True)
 
     assert resources == [a]
 
+
 def test_inter_library_dependencies_ordering():
     lib1 = Library('lib1', '')
     lib2 = Library('lib2', '')
     resources = needed.resources()
     assert resources == [style1, style2, js1, js2, js3]
 
+
 def test_library_ordering_bug():
     jquery_lib = Library('jquery', '')
     jqueryui_lib = Library('jqueryui', '')

tests/test_injector.py

     with pytest.raises(NotImplementedError):
         dummy.clear()
 
+
 def test_no_inject_into_non_html():
     foo = Library('foo', '')
     x1 = Resource(foo, 'a.js')
     request = webob.Request.blank('/')
     request.get_response(wrapped_app)
 
+
 def test_can_handle_no_content():
     foo = Library('foo', '')
     Resource(foo, 'a.js')

tests/test_publisher.py

+from datetime import datetime, timedelta
+
 import webob
 
-from datetime import datetime, timedelta
-
 from fanstatic import LibraryRegistry, Library, Publisher, Delegator, Resource
 from fanstatic.publisher import FOREVER
 
     assert response.status == '404 Not Found'
 
 
-
 def test_resource_version_skipped(tmpdir):
     foo_library_dir = tmpdir.mkdir('foo')
     resource = tmpdir.join('foo').join('test.js')
     response = request.get_response(publisher)
     assert response.status_int == 404
 
+
 def test_bundle_resources(tmpdir):
     foo_library_dir = tmpdir.mkdir('foo')
     foo = Library('foo', foo_library_dir.strpath)

tests/test_registry.py

     assert sorted(compat.iterkeys(library_registry)) == ['bar', 'baz', 'foo']
 
     # MyPackage has been installed in development mode:
-    assert library_registry['foo'].version == None
+    assert library_registry['foo'].version is None

tests/test_slot.py

+import pytest
+
 from fanstatic import NeededResources, Library, Resource, Slot, SlotError
-import pytest
+
 
 def test_fill_slot():
     needed = NeededResources()
     assert resources[0].library is b.library
     assert resources[0].relpath is b.relpath
 
+
 def test_dont_fill_required_slot():
     needed = NeededResources()
 
     b = Resource(lib, 'b.js')
 
     needed.need(a)
-    
+
     with pytest.raises(SlotError):
-        resources = needed.resources()
+        needed.resources()
+
 
 def test_no_need_to_fill_in_not_required():
     needed = NeededResources()
 
     # slot wasn't required and not filled in, so filled slot doesn't show up
     assert needed.resources() == [a]
-    
+
+
 def test_fill_slot_wrong_extension():
     needed = NeededResources()
 
     b = Resource(lib, 'b.css')
 
     needed.need(a, {slot: b})
-    
+
     with pytest.raises(SlotError):
-        resources = needed.resources()
+        needed.resources()
+
 
 def test_fill_slot_wrong_dependencies():
     needed = NeededResources()
-    
+
     lib = Library('lib', '')
 
     slot = Slot(lib, '.js')
     a = Resource(lib, 'a.js', depends=[slot])
 
     c = Resource(lib, 'c.js')
-    
+
     b = Resource(lib, 'b.js', depends=[c])
 
     needed.need(a, {slot: b})
 
     with pytest.raises(SlotError):
-        resources = needed.resources()
+        needed.resources()
+
 
 def test_render_filled_slots():
     needed = NeededResources()
 <script type="text/javascript" src="/fanstatic/lib/b.js"></script>
 <script type="text/javascript" src="/fanstatic/lib/a.js"></script>'''
 
+
 def test_slot_depends():
-    
+
     needed = NeededResources()
 
     lib = Library('lib', '')
     slot = Slot(lib, '.js', depends=[c])
     a = Resource(lib, 'a.js', depends=[slot])
     b = Resource(lib, 'b.js', depends=[c])
-    
+
     needed.need(a, {slot: b})
 
     assert needed.render() == '''\
 <script type="text/javascript" src="/fanstatic/lib/b.js"></script>
 <script type="text/javascript" src="/fanstatic/lib/a.js"></script>'''
 
+
 def test_slot_depends_subset():
     needed = NeededResources()
 
     slot = Slot(lib, '.js', depends=[c])
     a = Resource(lib, 'a.js', depends=[slot])
     b = Resource(lib, 'b.js', depends=[])
-    
+
     needed.need(a, {slot: b})
 
     assert needed.render() == '''\
 <script type="text/javascript" src="/fanstatic/lib/c.js"></script>
 <script type="text/javascript" src="/fanstatic/lib/b.js"></script>
 <script type="text/javascript" src="/fanstatic/lib/a.js"></script>'''
-    
+
+
 def test_slot_depends_incorrect():
     needed = NeededResources()
 
     a = Resource(lib, 'a.js', depends=[slot])
     d = Resource(lib, 'd.js')
     b = Resource(lib, 'b.js', depends=[d])
-    
+
     needed.need(a, {slot: b})
 
     with pytest.raises(SlotError):
         needed.render()
-  
+
+
 def test_slot_minified():
     needed = NeededResources(minified=True)
 

tests/test_wsgi.py

 import pytest
-
 import webob
 
 from fanstatic import (Library, Resource,
                        get_needed, make_serf, compat)
-
 from fanstatic import Fanstatic, ConfigurationError
 
 
     wrapped_app = Fanstatic(app, base_url='http://testapp')
 
     request = webob.Request.blank('/')
-    request.environ['SCRIPT_NAME'] = '/root' # base_url is defined so SCRIPT_NAME
-                                             # shouldn't be taken into account
+    request.environ['SCRIPT_NAME'] = '/root'  # base_url is defined so SCRIPT_NAME
+                                              # shouldn't be taken into account
     response = request.get_response(wrapped_app)
     assert response.body == b'''\
 <html><head>
 <script type="text/javascript" src="http://testapp/fanstatic/foo/c.js"></script>
 </head><body</body></html>'''
 
+
 def test_inject_script_name():
     foo = Library('foo', '')
     x1 = Resource(foo, 'a.js')
 <script type="text/javascript" src="/root/fanstatic/foo/c.js"></script>
 </head><body</body></html>'''
 
+
 def test_incorrect_configuration_options():
     app = None
     with pytest.raises(TypeError) as e:
         "__init__() got an unexpected "
         "keyword argument 'incorrect'") in str(e)
 
+
 def test_inject_unicode_base_url():
     foo = Library('foo', '')
     x1 = Resource(foo, 'a.js')
     request = webob.Request.blank('/')
     wrapped = Fanstatic(app, base_url=compat.u('http://localhost'))
     # Fanstatic used to choke on unicode content.
-    response = request.get_response(wrapped)
+    request.get_response(wrapped)
+
 
 def test_serf():
     pytest.importorskip('mypackage')
     # also test serf config
     d = {
         'resource': 'py:mypackage.style'
-        }
+    }
     serf = make_serf({}, **d)
     serf = Fanstatic(serf, versioning=False)
     request = webob.Request.blank('/')
     <link rel="stylesheet" type="text/css" href="/fanstatic/foo/style.css" />
 </head><body></body></html>'''
 
+
 def test_serf_unknown_library():
     d = {
         'resource': 'unknown_library:unknown_resource'
-        }
+    }
     with pytest.raises(ConfigurationError):
-        serf = make_serf({}, **d)
-
+        make_serf({}, **d)