enum-printers.py (1223B)
1 # Test that we can find pretty-printers for enums. 2 # flake8: noqa: F821 3 4 import mozilla.prettyprinters 5 6 7 @mozilla.prettyprinters.pretty_printer("unscoped_no_storage") 8 class UnscopedNoStoragePrinter: 9 def __init__(self, value, cache): 10 pass 11 12 def to_string(self): 13 return "unscoped_no_storage::success" 14 15 16 @mozilla.prettyprinters.pretty_printer("unscoped_with_storage") 17 class UnscopedWithStoragePrinter: 18 def __init__(self, value, cache): 19 pass 20 21 def to_string(self): 22 return "unscoped_with_storage::success" 23 24 25 @mozilla.prettyprinters.pretty_printer("scoped_no_storage") 26 class ScopedNoStoragePrinter: 27 def __init__(self, value, cache): 28 pass 29 30 def to_string(self): 31 return "scoped_no_storage::success" 32 33 34 @mozilla.prettyprinters.pretty_printer("scoped_with_storage") 35 class ScopedWithStoragePrinter: 36 def __init__(self, value, cache): 37 pass 38 39 def to_string(self): 40 return "scoped_with_storage::success" 41 42 43 run_fragment("enum_printers.one") 44 assert_pretty("i1", "unscoped_no_storage::success") 45 assert_pretty("i2", "unscoped_with_storage::success") 46 assert_pretty("i3", "scoped_no_storage::success") 47 assert_pretty("i4", "scoped_with_storage::success")