blob: d6b367ccf22ab86081abba7e92795a4d196d91d0 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#!/bin/sh
2
3[ "$1" = python3-constantly ] || exit 0
4
5python3 - << 'EOF'
6
7from constantly import NamedConstant, Names
8class Letters(Names):
9 a = NamedConstant()
10 b = NamedConstant()
11 c = NamedConstant()
12
13assert Letters.lookupByName('a') is Letters.a
14assert Letters.a < Letters.b
15assert Letters.b < Letters.c
16assert Letters.a < Letters.c
17
18from constantly import ValueConstant, Values
19class STATUS(Values):
20 OK = ValueConstant('200')
21 FOUND = ValueConstant('302')
22 NOT_FOUND = ValueConstant('404')
23
24assert STATUS.OK.value == '200'
25assert STATUS.lookupByValue('404') == STATUS.NOT_FOUND
26
27EOF