| 1 | # This is the testrecuset module. It contains code that tests the output and input of |
|---|
| 2 | # YAML with recursive sets. We also look at tuples. |
|---|
| 3 | |
|---|
| 4 | import yaml; |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | class C: |
|---|
| 8 | pass; |
|---|
| 9 | |
|---|
| 10 | c = C() |
|---|
| 11 | c.t = c; |
|---|
| 12 | s = set([c]) |
|---|
| 13 | c.s = s |
|---|
| 14 | |
|---|
| 15 | print "We print the object s" |
|---|
| 16 | print s; |
|---|
| 17 | D = yaml.dump(s); |
|---|
| 18 | print D; |
|---|
| 19 | E = yaml.load(D); |
|---|
| 20 | print E; |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | print "We print the class instance c." |
|---|
| 24 | print c; |
|---|
| 25 | D = yaml.dump(c); |
|---|
| 26 | print D; |
|---|
| 27 | E = yaml.load(D); #Not constructing c again?? |
|---|
| 28 | print E; |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | #print "CCC" |
|---|
| 32 | |
|---|
| 33 | #Q = "--- &A !!set { *A }" |
|---|
| 34 | #R = yaml.load(Q); |
|---|
| 35 | #print R; |
|---|
| 36 | |
|---|
| 37 | |
|---|