Anonymous avatar Anonymous committed bd29f96

Added a couple of actual unit tests, tagged functional test as functional

Comments (0)

Files changed (2)

nose2/tests/__init__.py

 SUPPORT = os.path.join(ROOT, 'support')
 
 
-class TestCase(unittest2.TestCase):
+class FunctionalTestCase(unittest2.TestCase):
+
+    tags = ['functional']
 
     def assertTestRunOutputMatches(self, proc, stdout=None, stderr=None):
         cmd_stdout, cmd_stderr = proc.communicate()

nose2/tests/test_logcapture_plugin.py

+import logging
 import re
+import unittest2
 
-from . import TestCase
+from . import FunctionalTestCase
+from ..plugins.logcapture import LogCapture
 
 
-class TestLogcaptureOutputIncluded(TestCase):
+log = logging.getLogger(__name__)
+
+
+class LogCaptureFunctionalTest(FunctionalTestCase):
     def test_layout2(self):
         match = re.compile('>> begin captured logging <<')
         self.assertTestRunOutputMatches(
             self.runIn('layout2'),
             stderr=match)
+
+
+class LogCaptureUnitTest(unittest2.TestCase):
+
+    tags = ['unit']
+
+    def setUp(self):
+        self.plugin = LogCapture()
+
+    def event(self, error=True, failed=False):
+        e = Event
+        e.error = True
+        e.failed = False
+        e.traceback = ''
+        e.metadata = {}
+        return e
+
+    def test_buffer_cleared_after_each_test(self):
+        self.plugin.startTestRun(None)
+        self.plugin.startTest(None)
+        log.debug("hello")
+        assert self.plugin.handler.buffer
+        self.plugin.stopTest(self.event())
+        assert not self.plugin.handler.buffer
+
+    def test_buffered_logs_attached_to_event(self):
+        self.plugin.startTestRun(None)
+        self.plugin.startTest(None)
+        log.debug("hello")
+        assert self.plugin.handler.buffer
+        e = self.event()
+        self.plugin.stopTest(e)
+        assert 'logs' in e.metadata, "No log in %s" % e.metadata
+        assert e.traceback
+
+
+
+class Event:
+    pass
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.