Jaymon / testdata

Python module to make testing easier, it can generate random data like names and text, run commands, fetch urls, create files and directories, and more
MIT License
10 stars 0 forks source link

testdata.duck #35

Open Jaymon opened 6 years ago

Jaymon commented 6 years ago

as discussed in https://github.com/Jaymon/testdata/issues/32 I think I should add a testdata.duck that can take an object and produce an object similar to the passed in object, but it should also have the ability to convert it into a dict and things like that, so if I had something like:

class Foo(object):
    bar = 1
    che = 2

I could do this:

f = Foo()
print(f.bar) # 1

duck = testdata.duck(f)
print(duck.bar) # 1
print(duck.duckdict["bar"]) # 1

You could have a whole host of duck* methods on the duck-typed class