Some cleanups of the unittests.

This commit is contained in:
Griatch 2014-03-15 07:37:02 +01:00
parent cafbb43f7a
commit 7571e3606d
5 changed files with 8 additions and 29 deletions

View file

@ -78,6 +78,7 @@ class CommandTest(TestCase):
CID = 0 # we must set a different CID in every test to avoid unique-name collisions creating the objects CID = 0 # we must set a different CID in every test to avoid unique-name collisions creating the objects
def setUp(self): def setUp(self):
"sets up testing environment" "sets up testing environment"
print "creating player %i: %s" % (self.CID, self.__class__.__name__)
self.player = create.create_player("TestPlayer%i" % self.CID, "test@test.com", "testpassword", typeclass=TestPlayerClass) self.player = create.create_player("TestPlayer%i" % self.CID, "test@test.com", "testpassword", typeclass=TestPlayerClass)
self.player2 = create.create_player("TestPlayer%ib" % self.CID, "test@test.com", "testpassword", typeclass=TestPlayerClass) self.player2 = create.create_player("TestPlayer%ib" % self.CID, "test@test.com", "testpassword", typeclass=TestPlayerClass)
self.room1 = create.create_object("src.objects.objects.Room", key="Room%i"%self.CID, nohome=True) self.room1 = create.create_object("src.objects.objects.Room", key="Room%i"%self.CID, nohome=True)

View file

@ -26,37 +26,20 @@ try:
except ImportError: except ImportError:
import unittest import unittest
from src.commands.default import tests as commandtests
from src.locks import tests as locktests from src.locks import tests as locktests
from src.utils import tests as utiltests
from src.commands.default import tests as commandtests
class TestObjAttrs(TestCase):
"""
Test aspects of ObjAttributes
"""
pass
# def setUp(self):
# "set up the test"
# self.attr = models.ObjAttribute()
# self.obj1 = create.create_object(objects.Object, key="testobj1", location=None)
# self.obj2 = create.create_object(objects.Object, key="testobj2", location=self.obj1)
# def test_store_str(self):
# hstring = u"sdfv00=97sfjs842 ivfjlQKFos9GF^8dddsöäå-?%"
# self.obj1.db.testattr = hstring
# self.assertEqual(hstring, self.obj1.db.testattr)
# def test_store_obj(self):
# self.obj1.db.testattr = self.obj2
# self.assertEqual(self.obj2 ,self.obj1.db.testattr)
# self.assertEqual(self.obj2.location, self.obj1.db.testattr.location)
def suite(): def suite():
""" """
This function is called automatically by the django test runner. This function is called automatically by the django test runner.
This also runs the command tests defined in src/commands/default/tests.py. This also collates tests from packages that are not formally django applications.
""" """
tsuite = unittest.TestSuite() tsuite = unittest.TestSuite()
tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__])) tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__]))
# test modules from non-django apps
tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(commandtests)) tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(commandtests))
tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(locktests)) tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(locktests))
tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(utiltests))
return tsuite return tsuite

View file

@ -515,7 +515,6 @@ INSTALLED_APPS = (
'src.comms', 'src.comms',
'src.help', 'src.help',
'src.scripts', 'src.scripts',
'src.utils',
'src.web.news', 'src.web.news',
'src.web.website',) 'src.web.website',)
# The user profile extends the User object with more functionality; # The user profile extends the User object with more functionality;

View file

@ -491,7 +491,7 @@ def create_player(key, email, password,
if not email: if not email:
email = "dummy@dummy.com" email = "dummy@dummy.com"
if _PlayerDB.objects.filter(username__iexact=key): if _PlayerDB.objects.filter(username__iexact=key):
raise ValueError("A Player with this name already exists.") raise ValueError("A Player with the name '%s' already exists." % key)
# this handles a given dbref-relocate to a player. # this handles a given dbref-relocate to a player.
report_to = handle_dbref(report_to, _PlayerDB) report_to = handle_dbref(report_to, _PlayerDB)

View file

@ -1,4 +0,0 @@
"""
Dummy models.py file to allow us to add utils to the apps list so Django's
test runner will recognize it.
"""