Forcing unit test runner to abort after failed test

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
from django.test import TestCase

class SimpleTest(TestCase):
    ''' Your unit tests go here '''  

    def test_a(self):
        pass
  
  
    def run(self, result=None):
        if result is None: result = self.defaultTestResult()
        try:
            super(SimpleTest, self).run(result)
        except KeyboardInterrupt:
            result.stop()
      

More like this

  1. Exclude Apps When Testing by cronosa 2 years, 8 months ago
  2. Variable._resolve_lookup monkeypatch by showell 3 years, 7 months ago
  3. UnitTesting without create/destroy database by crucialfelix 4 years, 4 months ago
  4. Stop tests at the first failure by akaihola 5 years, 5 months ago
  5. Testing for failure in management commands by David 2 years, 10 months ago

Comments

akaihola (on February 26, 2008):

See also snippet 534 for how to make the unit tests always stop after the first failure.

#

(Forgotten your password?)