Beispiel #1
0
#!/usr/bin/env python3

import foo

print(dir(foo.Foo))
print(foo.Foo.__doc__)

f = foo.Foo(None, 2)

print(f.get_bar())
print(f.get_hundred())
print(f.get_a())
f.set_a(30)
print(f.get_a())
print(f.a)
f.a = 1
print(f.a)
f.set_bar("as")
print(f.bar)
print(f.get_bar())
Beispiel #2
0
def foo_obj():
    return foo.Foo()
Beispiel #3
0
def test_foo_init():
    '''
    Tests that constructor correctly sets members.
    '''
    instance = foo.Foo(42)
    assert instance.baz == 42
Beispiel #4
0

def get_indirect():
    return foo.get_foo() + ' and bar'


def get_direct():
    return get_foo() + ' and bar'


def get_internal():
    from foo import get_foo
    return get_foo() + ' and bar'


glob_obj1 = foo.Foo()
glob_obj2 = Foo()
glob_obj3 = Foo(attr='overridden')


def get_glob_objs():
    return ((glob_obj1.get(), glob_obj1.get_class_attr()),
            (glob_obj2.get(), glob_obj2.get_class_attr()),
            (glob_obj3.get(), glob_obj3.get_class_attr()))


def get_objs():
    obj1 = foo.Foo()
    obj2 = Foo()
    obj3 = Foo(attr='overridden')
 def test_attribute_with_getset(self):
     obj = foo.SomeObject("")
     f1 = foo.Foo("hello")
     obj.foo = f1
     f2 = obj.foo
     self.assertEqual(f2.get_datum(), "hello")
 def test_output_stream(self):
     f = foo.Foo("hello")
     self.assertEqual(str(f), "hello")
Beispiel #7
0
#!/usr/bin/python

import foo

bar = foo.Foo()
bar.show_int(5)

print "Creating object..."
moo = foo.FooObj()
bar.show_obj(moo)

print "Assigning members..."
moo.a = 1
moo.b = 2
bar.show_obj(moo)

print "Load values from lib..."
bar.load_obj(moo)
bar.show_obj(moo)

 def test_custom_instance_attribute(self):
     obj = foo.Foo()
     if foo.Foo.instance_count == 1:
         self.assertTrue(obj.is_unique)
     else:
         self.assertFalse(obj.is_unique)
Beispiel #9
0
 def test_new(self):
     foo.Foo()
def main():
    f = foo.Foo()
    f.print()
Beispiel #11
0
 def setUp(self):
     self.foo=foo.Foo()
Beispiel #12
0
 def test_bar(self):
     f = foo.Foo()
     self.assertEqual(f.x, 42)
Beispiel #13
0
def test_foo_init_bar_negative():
    '''
    Tests that constructor raises exception when baz is negative.
    '''
    with pytest.raises(ValueError):
        foo.Foo(-1)
Beispiel #14
0
def test():
	foo = foo.Foo()
	bar = bar.Bar()
Beispiel #15
0
def fooobj():
    return foo.Foo(42)
Beispiel #16
0
# file: runme.py
# Test various properties of classes defined in separate modules

print("Testing the %import directive")
import base
import foo
import bar
import spam

# Create some objects

print("Creating some objects")

a = base.Base()
b = foo.Foo()
c = bar.Bar()
d = spam.Spam()

# Try calling some methods
print("Testing some methods")
print("", end=' ')
print("Should see 'Base::A' ---> ", end=' ')
a.A()
print("Should see 'Base::B' ---> ", end=' ')
a.B()

print("Should see 'Foo::A' ---> ", end=' ')
b.A()
print("Should see 'Foo::B' ---> ", end=' ')
b.B()
Beispiel #17
0
import foo

f = foo.Foo("Joe")
print "C++ Foo.name is %s" % (f.name)
f.speak()

f.rename("Nancy")
print "C++ Foo.name is %s" % (f.name)
f.speak()

foo.meet_friend(f, "Ted")
 def test_foo(self):
     f = foo.Foo("hello")
     self.assertEqual(f.get_datum(), "hello")
Beispiel #19
0
 def testTrue(self):
     f = foo.Foo()
     self.failUnlessEqual(f.foo(True), True)
    def test_instance_creation_function(self):
        f = foo.Foo()
        self.assertTrue(f.is_initialized())

        b = foo.Bar()
        self.assertTrue(b.is_initialized())
Beispiel #21
0
 def testFalse(self):
     f = foo.Foo()
     self.failUnlessEqual(f.foo(False), False)
Beispiel #22
0
while True:
    line = proc.stdout.readline()
    print("line: %s" % line)

########################################################
# Conditional import and testing imported libraries
########################################################

try:
    import foo
except:
    pass
import sys

if 'foo' in sys.modules:
    myfoo = foo.Foo()
else:
    myfoo = None

########################################################
# OS-specific stuff
########################################################

# Read keys in cbreak mode.
# Some info at:
# http://docs.python.org/2/faq/library.html#how-do-i-get-a-single-keypress-at-a-time
# but it's incomplete, so see
# https://github.com/akkana/scripts/blob/master/keyreader.py
# for a better solution.
#
# Of course, you can also do this with curses.
 def setUp(self):
     self.FOO = foo.Foo()