test_extending.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #! /usr/bin/env python
  2. # Copyright Ralf W. Grosse-Kunstleve 2006. Distributed under the Boost
  3. # Software License, Version 1.0. (See accompanying
  4. # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. # Using the doctest module here to ensure that the results are as expected.
  6. r'''>>> from extending import *
  7. >>> hi = hello('California')
  8. >>> hi.greet()
  9. 'Hello from California'
  10. >>> invite(hi)
  11. 'Hello from California! Please come soon!'
  12. >>> hi.invite()
  13. 'Hello from California! Please come soon!'
  14. >>> class wordy(hello):
  15. ... def greet(self):
  16. ... return hello.greet(self) + ', where the weather is fine'
  17. ...
  18. >>> hi2 = wordy('Florida')
  19. >>> hi2.greet()
  20. 'Hello from Florida, where the weather is fine'
  21. >>> invite(hi2)
  22. 'Hello from Florida! Please come soon!'
  23. '''
  24. def run(args = None):
  25. if args is not None:
  26. import sys
  27. sys.argv = args
  28. import doctest, test_extending
  29. return doctest.testmod(test_extending, verbose=True)
  30. if __name__ == '__main__':
  31. import sys
  32. sys.exit(run()[0])