staticmethod.py 771 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright David Abrahams 2004. Distributed under the Boost
  2. # Software License, Version 1.0. (See accompanying
  3. # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. '''
  5. >>> from staticmethod_ext import *
  6. >>> class X1(X):
  7. ... pass
  8. >>> x = X(16)
  9. >>> x1 = X1(17)
  10. >>> x1.count()
  11. 2
  12. >>> x.count()
  13. 2
  14. >>> X1.count()
  15. 2
  16. >>> X.count()
  17. 2
  18. >>> x1.magic()
  19. 7654321
  20. >>> x.magic()
  21. 7654321
  22. >>> X1.magic()
  23. 7654321
  24. >>> X.magic()
  25. 7654321
  26. '''
  27. def run(args = None):
  28. import sys
  29. import doctest
  30. if args is not None:
  31. sys.argv = args
  32. return doctest.testmod(sys.modules.get(__name__))
  33. if __name__ == '__main__':
  34. print("running...")
  35. import sys
  36. status = run()[0]
  37. if (status == 0): print("Done.")
  38. sys.exit(status)