usnews/smoketest

Support boolean attributes more gracefully in YAML expectations files

Opened this issue · 0 comments

For a URL such as https://www.theatlantic.com/amp/article/561986/, it has this HTML:

<html amp lang="en">

Testing this amp boolean attribute is a bit annoying. The text matching method is currently required, so a workaround is doing this:

-   directive: check
    url: https://www.theatlantic.com/amp/article/561986/
    html:
    -   selector: html
        attribute: amp
        contains: ''

But something like this should probably just work as expected:

-   directive: check
    url: https://www.theatlantic.com/amp/article/561986/
    html:
    -   selector: html
        attribute: amp

Instead it throws this error:

mmcbride@local:~/Documents/git/smoketests$ ./venv/bin/smoketest -vv expectations/boolean-attributes.yaml 
.Exception in thread Thread-16:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Users/mmcbride/Documents/git/smoketests/venv/lib/python2.7/site-packages/smoketest/threads.py", line 26, in runner
    directive.run()
  File "/Users/mmcbride/Documents/git/smoketests/venv/lib/python2.7/site-packages/smoketest/directives.py", line 173, in run
    failed_urls_ |= self._run_for_platform(platform)
  File "/Users/mmcbride/Documents/git/smoketests/venv/lib/python2.7/site-packages/smoketest/directives.py", line 197, in _run_for_platform
    self.logger.log_test_result(url, test, result, response, platform, self.follow_redirects)
  File "/Users/mmcbride/Documents/git/smoketests/venv/lib/python2.7/site-packages/smoketest/loggers.py", line 123, in log_test_result
    if result:
  File "/Users/mmcbride/Documents/git/smoketests/venv/lib/python2.7/site-packages/smoketest/tests.py", line 386, in __nonzero__
    match = self.test.text_matching_method(self._string_to_test)
TypeError: 'NoneType' object is not callable


Elapsed time: 2.42500805855
Number of successes: 1
Number of failures: 0
Number of errors: 0