Django UrlResolver, adding urls at runtime for testing

Since Django 1.8 using of django.test.TestCase.urls is deprecated. You can use django.test.utils.override_settings instead: from django.test import TestCase from django.test.utils import override_settings urlpatterns = [ # custom urlconf ] @override_settings(ROOT_URLCONF=__name__) class MyTestCase(TestCase): pass override_settings can be applied either to a whole class or to a particular method.

Testing for exceptions with [TestCase] attribute in NUnit 3?

ExpectedException would have been the correct method for NUnit 2.X, but it was removed from NUnit 3. There’s a various snippets of discussion in the NUnit Google Group and the equivalent Dev group – but it looks like the decision was made that it’s generally a better design pattern to test expected outcomes, and exceptions … Read more

How do I put new List {1} in an NUNIT TestCase?

There is one option to use TestCaseSource attribute. Here I provide a non-assert test with two cases just to see how it works: [TestFixture] public class TestClass { private static readonly object[] _sourceLists = { new object[] {new List<int> {1}}, //case 1 new object[] {new List<int> {1, 2}} //case 2 }; [TestCaseSource(“_sourceLists”)] public void Test(List<int> … Read more

Persist variable changes between tests in unittest?

As some comments have echoed, structuring your tests in this manner is probably a design flaw in the tests themselves and you should consider restructuring them. However, if you want to do this and rely on the fact that the test runner you are using executes them in an alphabetical (seemingly) order then I suggest … Read more