def start(recipes, options={}): test(recipes, options=options) from django.contrib.auth.models import User u = User.objects.create( username='******', email='*****@*****.**', is_superuser=True, is_staff=True, is_active=True ) u.set_password("admin") u.save() for recipe in recipes: call_command('loaddata', recipe) call_command('sqlall', recipe) call_command('runserver', '0.0.0.0:8000', use_reloader=False)
def run(self, result): if self.testCaseClass: first = True test = None for test in self._tests: if result.shouldStop: test = None break if first: first = False if test.loadonce: test._pre_setup_real() test.initialize() test(result) if test and test.loadonce: test._post_teardown_real() return result else: return super(TestCaseSuite, self).run(result)
def run(self, result): if self.testCaseClass: first = True test = None for test in self._tests: if result.shouldStop: test = None break if first: first = False if test.loadonce: test._pre_setup_real() test.initialize() test(result) if test and test.loadonce: test._post_teardown_real() return result else: return super(TestCaseSuite,self).run(result)
def test_new(self): self.client.login(username=self.testuser.username, password=TESTUSER_PASSWORD) test(self, *args, **kwargs)
for fle in fles: abspath = os.path.join(path, fle) data = open(abspath, "rb").read() data = data.replace(old, new) out = open(abspath, "wb") out.write(data) def main(): try: opts, args = getopt.getopt(sys.argv[1:], "htsi", ["help", "test", "start",]) except getopt.GetoptError, err: print str(err) usage() sys.exit(2) recipes = validate_options(*args) for o, a in opts: if o in ("--h", "--help"): usage() sys.exit() elif o in ("-t", "--test"): test(recipes, options=dict(opts)) elif o in ("-s", "--start"): start(recipes, options=dict(opts)) #elif o in ("-i"): # insert(recipes, options=dict(opts)) if __name__ == "__main__": main()
def test_get_for_object(self): self.create_comment_for_story1() test = Comment.objects.get_for_object self.assertEquals(1, test(self.story_1).count()) self.assertEquals(0, test(self.story_2).count())