Решение на Регулярни изрази от Снежана Спасова
Обратно към всички решения
Към профила на Снежана Спасова
Резултати
- 6 точки от тестове
- 0 бонус точки
- 6 точки общо
- 25 успешни тест(а)
- 14 неуспешни тест(а)
Код
Лог от изпълнението
F..FFE.F.E.....EFF....F...FF.......F..F
======================================================================
ERROR: test_filters_more_complex_phone_numbers (test.PrivacyFilterTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140513-11348-1hv0kp3/test.py", line 76, in test_filters_more_complex_phone_numbers
self.assertEqual(filtered, solution.PrivacyFilter(text).filtered())
File "/tmp/d20140513-11348-1hv0kp3/solution.py", line 48, in filtered
self.text = re.sub(phone.group(), '[PHONE]', self.text)
File "/opt/python3.3/lib/python3.3/re.py", line 170, in sub
return _compile(pattern, flags).sub(repl, string, count)
File "/opt/python3.3/lib/python3.3/functools.py", line 258, in wrapper
result = user_function(*args, **kwds)
File "/opt/python3.3/lib/python3.3/re.py", line 274, in _compile
return sre_compile.compile(pattern, flags)
File "/opt/python3.3/lib/python3.3/sre_compile.py", line 493, in compile
p = sre_parse.parse(p, flags)
File "/opt/python3.3/lib/python3.3/sre_parse.py", line 724, in parse
p = _parse_sub(source, pattern, 0)
File "/opt/python3.3/lib/python3.3/sre_parse.py", line 347, in _parse_sub
itemsappend(_parse(source, state))
File "/opt/python3.3/lib/python3.3/sre_parse.py", line 552, in _parse
raise error("nothing to repeat")
sre_constants.error: nothing to repeat
======================================================================
ERROR: test_preserves_whitespace_around_phones (test.PrivacyFilterTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140513-11348-1hv0kp3/test.py", line 89, in test_preserves_whitespace_around_phones
self.assertEqual(' [PHONE] or...', solution.PrivacyFilter(' +359881212-12-1 2 or...').filtered())
File "/tmp/d20140513-11348-1hv0kp3/solution.py", line 48, in filtered
self.text = re.sub(phone.group(), '[PHONE]', self.text)
File "/opt/python3.3/lib/python3.3/re.py", line 170, in sub
return _compile(pattern, flags).sub(repl, string, count)
File "/opt/python3.3/lib/python3.3/functools.py", line 258, in wrapper
result = user_function(*args, **kwds)
File "/opt/python3.3/lib/python3.3/re.py", line 274, in _compile
return sre_compile.compile(pattern, flags)
File "/opt/python3.3/lib/python3.3/sre_compile.py", line 493, in compile
p = sre_parse.parse(p, flags)
File "/opt/python3.3/lib/python3.3/sre_parse.py", line 724, in parse
p = _parse_sub(source, pattern, 0)
File "/opt/python3.3/lib/python3.3/sre_parse.py", line 347, in _parse_sub
itemsappend(_parse(source, state))
File "/opt/python3.3/lib/python3.3/sre_parse.py", line 552, in _parse
raise error("nothing to repeat")
sre_constants.error: nothing to repeat
======================================================================
ERROR: test_can_validate_more_complex_emails (test.ValidationsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140513-11348-1hv0kp3/test.py", line 124, in test_can_validate_more_complex_emails
self.assertIs(solution.Validations.is_email(email), valid)
File "/tmp/d20140513-11348-1hv0kp3/solution.py", line 58, in is_email
username, hostname = value.split('@')
ValueError: too many values to unpack (expected 2)
======================================================================
FAIL: test_allows_email_hostname_to_be_preserved (test.PrivacyFilterTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140513-11348-1hv0kp3/test.py", line 55, in test_allows_email_hostname_to_be_preserved
self.assertEqual('[FILTERED]@exa.mple.com', self.filter_email_usernames('some12-+3@exa.mple.com'))
AssertionError: '[FILTERED]@exa.mple.com' != 'some12-+3@exa.mple.com'
- [FILTERED]@exa.mple.com
+ some12-+3@exa.mple.com
======================================================================
FAIL: test_does_not_filter_invalid_emails (test.PrivacyFilterTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140513-11348-1hv0kp3/test.py", line 48, in test_does_not_filter_invalid_emails
self.assertEqual(text, solution.PrivacyFilter(text).filtered())
AssertionError: 'Contact me here: _invalid@email.com' != 'Contact me here: _[EMAIL]'
- Contact me here: _invalid@email.com
+ Contact me here: _[EMAIL]
======================================================================
FAIL: test_does_not_filter_invalid_phone_numbers (test.PrivacyFilterTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140513-11348-1hv0kp3/test.py", line 86, in test_does_not_filter_invalid_phone_numbers
self.assertEqual(filtered, solution.PrivacyFilter(text).filtered())
AssertionError: '0005551234569' != '0[PHONE]'
- 0005551234569
+ 0[PHONE]
======================================================================
FAIL: test_obfuscates_more_complicated_emails (test.PrivacyFilterTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140513-11348-1hv0kp3/test.py", line 37, in test_obfuscates_more_complicated_emails
self.assertEqual(filtered, solution.PrivacyFilter(text).filtered())
AssertionError: '[EMAIL]' != 'some.user+and-more-here@lawn.co.uk'
- [EMAIL]
+ some.user+and-more-here@lawn.co.uk
======================================================================
FAIL: test_can_validate_more_complex_phone_numbers (test.ValidationsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140513-11348-1hv0kp3/test.py", line 160, in test_can_validate_more_complex_phone_numbers
self.assertIs(solution.Validations.is_phone(phone), valid)
AssertionError: True is not False
======================================================================
FAIL: test_does_not_allow_invalid_hours_minutes_or_seconds (test.ValidationsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140513-11348-1hv0kp3/test.py", line 273, in test_does_not_allow_invalid_hours_minutes_or_seconds
self.assertFalse(solution.Validations.is_time('12:1:9'))
AssertionError: True is not false
======================================================================
FAIL: test_handles_multiline_strings_in_IP_validation_properly (test.ValidationsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140513-11348-1hv0kp3/test.py", line 189, in test_handles_multiline_strings_in_IP_validation_properly
self.assertFalse(solution.Validations.is_ip_address("8.8.8.8\n"))
AssertionError: True is not false
======================================================================
FAIL: test_handles_newlines_in_date_validation (test.ValidationsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140513-11348-1hv0kp3/test.py", line 259, in test_handles_newlines_in_date_validation
self.assertFalse(solution.Validations.is_date("2012-11-19\n"))
AssertionError: True is not false
======================================================================
FAIL: test_handles_newlines_in_time_and_datetime_validation (test.ValidationsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140513-11348-1hv0kp3/test.py", line 288, in test_handles_newlines_in_time_and_datetime_validation
self.assertFalse(solution.Validations.is_time("12:01:01\n"))
AssertionError: True is not false
======================================================================
FAIL: test_validates_more_complex_numbers (test.ValidationsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140513-11348-1hv0kp3/test.py", line 207, in test_validates_more_complex_numbers
self.assertTrue(solution.Validations.is_number('0.0'))
AssertionError: False is not true
======================================================================
FAIL: test_validates_times (test.ValidationsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "lib/language/python/runner.py", line 60, in thread
raise it.exc_info[1]
File "lib/language/python/runner.py", line 48, in run
self.result = func(*args, **kwargs)
File "/tmp/d20140513-11348-1hv0kp3/test.py", line 267, in test_validates_times
self.assertFalse(solution.Validations.is_time('3:59:59'))
AssertionError: True is not false
----------------------------------------------------------------------
Ran 39 tests in 0.045s
FAILED (failures=11, errors=3)
История (2 версии и 0 коментара)
Снежана обнови решението на 23.04.2014 04:24 (преди над 10 години)
Снежана обнови решението на 23.04.2014 05:08 (преди над 10 години)