changeset 2248:0131f0aabb18

merged main
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 22 Jun 2007 14:05:40 +0200
parents d782b0db4757 (current diff) 0893eaf60bbf (diff)
children d48a4d0a0c70 ece659592dd9 691b6a650d94
files
diffstat 2 files changed, 27 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_packages.py	Fri Jun 22 14:05:11 2007 +0200
+++ b/MoinMoin/_tests/test_packages.py	Fri Jun 22 14:05:40 2007 +0200
@@ -6,7 +6,6 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-from unittest import TestCase
 
 import py
 
@@ -15,6 +14,7 @@
 from MoinMoin.packages import Package, ScriptEngine, MOIN_PACKAGE_FILE, packLine, unpackLine
 
 
+
 class DebugPackage(Package, ScriptEngine):
     """ Used for debugging, does not need a real .zip file. """
     def __init__(self, request, filename, script=None):
@@ -26,6 +26,7 @@
 ReplaceUnderlay|testdatei|TestSeite2
 IgnoreExceptions|True
 DeletePage|TestSeiteDoesNotExist|Test ...
+DeletePage|FooPage|Test ...
 IgnoreExceptions|False
 AddRevision|foofile|FooPage
 AddRevision|foofile|FooPage
@@ -46,29 +47,40 @@
     def isPackage(self):
         return True
 
-class TestUnsafePackage(TestCase):
+
+class TestUnsafePackage:
     """ Tests various things in the packages package. Note that this package does
         not care to clean up and needs to run in a test wiki because of that. """
 
-    def setUp(self):
+    def setup_class(self):
         if not getattr(self.request.cfg, 'is_test_wiki', False):
             py.test.skip('This test needs to be run using the test wiki.')
 
-    def testBasicPackageThings(self):
-        myPackage = DebugPackage(self.request, 'test')
-        myPackage.installPackage()
-        self.assertEqual(myPackage.msg, "foo\n")
-        testseite2 = Page(self.request, 'TestSeite2')
-        self.assertEqual(testseite2.getPageText(), "Hello world, I am the file testdatei")
-        self.assert_(testseite2.isUnderlayPage())
 
-    def tearDown(self):
+    def teardown_class(self):
         DebugPackage(self.request, u"""moinmoinpackage|1
 DeletePage|FooPage|Test ...
 """).installPackage()
 
-class TestQuoting(TestCase):
+    def gain_superuser_rights(self):
+        self.request.user.name = "SuperUserName"
+        self.request.user.valid = 1
+        self.request.user.may.name = self.request.user.name
+        self.request.cfg.superuser.append(self.request.user.name)
+        self.request.user.auth_method = self.request.cfg.trusted_auth_methods[0]
+
+    def testBasicPackageThings(self):
+        self.gain_superuser_rights()
+        myPackage = DebugPackage(self.request, 'test')
+        myPackage.installPackage()
+        assert myPackage.msg == u'foo\nFooPage added \n'
+        testseite2 = Page(self.request, 'TestSeite2')
+        assert testseite2.getPageText() == "Hello world, I am the file testdatei"
+        assert testseite2.isUnderlayPage()
+
+
+class TestQuoting:
     def testQuoting(self):
         for line in ([':foo', 'is\\', 'ja|', u't|', u'baAz'], [], ['', '']):
-            self.assertEqual(line, unpackLine(packLine(line)))
+            assert line == unpackLine(packLine(line))
 
--- a/MoinMoin/_tests/test_wikisync.py	Fri Jun 22 14:05:11 2007 +0200
+++ b/MoinMoin/_tests/test_wikisync.py	Fri Jun 22 14:05:40 2007 +0200
@@ -6,7 +6,7 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-from unittest import TestCase
+from unittest import TestCase # LEGACY UNITTEST, PLEASE DO NOT IMPORT unittest IN NEW TESTS, PLEASE CONSULT THE py.test DOCS
 
 import py
 
@@ -36,3 +36,4 @@
     def tearDown(self):
         tags = TagStore(self.page)
         tags.clear()
+