To jest mój funkcji: functionoświadczenie Wyjątek nieobjęte self.assertRaises pyton jednostkowych przypadków testowych
def get_value(request, param):
s = get_string(request, param)
value = re.search('(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)', s)
if not value:
print 'match not found!'
raise Exception('incorrect format: %s' % param)
Test:
def test_get_value(self):
m = test_mocks.HttpRequestMock(REQUEST = {'start_date': '2011.07.31'})
print '*************************'
print 'date format changed'
self.assertRaises(Exception, get_value, (m, 'start_date'))
print '*********************
get_value
nie drukuje: mecz nie został znaleziony!
dziękuje Brenowi za montaż. –
Twój 'helpers.get_date_param' nazywa' get_value'? – Ian
zmieniono połączenie ... zmieniłem nazwę funkcji, aby opublikować pytanie tutaj! –