1. Ben Bangert
  2. dozer

Commits

Marius Gedminas  committed 5623623
  • Participants
  • Parent commits 354a116
  • Branches trunk

Comments (0)

Files changed (6)

File .hgignore

View file
 *.egg
 .*.swp
 tmp/
+.tox/
+bin/
+include/
+lib/
+local/
+man/
 
 # Automatically generated by `hgimportsvn`
 syntax:glob

File Makefile

View file
 FILE_WITH_CHANGELOG = CHANGELOG.rst
 
 
-all:
-	# There's nothing that needs building in Dozer.
+all: bin/nosetests bin/detox bin/tox bin/coverage lib/python*/site-packages/Dozer.egg-link
 
-test:
-	# No tests yet :(
+test: bin/nosetests lib/python*/site-packages/Dozer.egg-link
+	bin/nosetests
+
+coverage: bin/nosetests bin/coverage lib/python*/site-packages/Dozer.egg-link
+	bin/nosetests --with-coverage --cover-erase --cover-inclusive --cover-package=dozer
+
+clean:
+	rm -rf bin include lib local man
 
 dist:
 	$(PYTHON) setup.py sdist
 
 
 .PHONY: all test dist distcheck releasechecklist release
+
+bin/nosetests: bin/pip
+	bin/pip install -M nose
+
+bin/tox: bin/pip
+	bin/pip install -M tox
+
+bin/detox: bin/pip
+	bin/pip install -M detox
+
+bin/coverage: bin/pip
+	bin/pip install -M coverage
+
+lib/python*/site-packages/Dozer.egg-link:
+	bin/pip install -M -e .
+
+bin/pip:
+	virtualenv .

File dozer/leak.py

View file
     except ImportError:
         ImageDraw = None
 
-from paste import fileapp
 from paste import urlparser
 from pkg_resources import resource_filename
 from webob import Request, Response
         self.path = path
         self.history = {}
         self.samples = 0
+        self._start_thread()
+        self._maybe_warn_about_PIL()
+
+    def _start_thread(self):
         self.runthread = threading.Thread(name='Dozer', target=self.start)
         self.runthread.setDaemon(True)
         self.runthread.start()
+
+    def _maybe_warn_about_PIL(self):
         if Image is None or ImageDraw is None:
             warnings.warn('PIL is not installed, cannot show charts in Dozer')
 
                 typecounts[objtype] = 1
 
         for objtype, count in typecounts.iteritems():
-            typename = objtype.__module__ + "." + objtype.__name__
+            typename = "%s.%s" % (objtype.__module__, objtype.__name__)
             if typename not in self.history:
                 self.history[typename] = [0] * self.samples
             self.history[typename].append(count)

File dozer/tests/test_leak.py

View file
+import unittest
+
+from dozer.leak import Dozer
+
+
+class DozerForTests(Dozer):
+    def __init__(self, app=None, *args, **kw):
+        super(DozerForTests, self).__init__(app, *args, **kw)
+    def _start_thread(self):
+        pass
+    def _maybe_warn_about_PIL(self):
+        pass
+
+
+class EvilProxyClass(object):
+
+    def __init__(self, obj):
+        self.obj = obj
+
+    @property
+    def __module__(self):
+        return self.obj.__module__
+
+    @property
+    def __name__(self):
+        return self.obj.__name__
+
+
+class TestDozer(unittest.TestCase):
+
+    def test_tick_handles_types_with_broken_module(self):
+        # https://bitbucket.org/bbangert/dozer/issue/3/cannot-user-operator-between-property-and
+        dozer = DozerForTests()
+        evil_proxy = EvilProxyClass(object) # keep a reference to it
+        dozer.tick()
+

File setup.cfg

-[egg_info]
-#tag_build = dev
-#tag_date = true
-
-[nosetests]
-# constrain nosetests to the tests dir for now: 0.10 ends up
-# overwriting pylons.config with the actual module
-where=tests
-verbose=True
-verbosity=2
-detailed-errors=True
-with-doctest=True

File tox.ini

View file
+[tox]
+envlist = py26, py27
+
+[testenv]
+deps = nose
+commands = nosetests