Exemplo n.º 1
0
    def test_on_peu_voter_entre_deux_foo(self):
        foo1 = Foo('machin')
        foo2 = Foo('truc')

        foo1.a_vaincu(foo2)

        self.assertEqual(1500. + K / 2, foo1.score)
        self.assertEqual(1500. - K / 2, foo2.score)
Exemplo n.º 2
0
def get_objs():
    obj1 = foo.Foo()
    obj2 = Foo()
    obj3 = Foo(attr='overridden')

    return ((obj1.get(), obj1.get_class_attr()),
            (obj2.get(), obj2.get_class_attr()), (obj3.get(),
                                                  obj3.get_class_attr()))
Exemplo n.º 3
0
    def test_on_peut_avoir_deux_foo_aleatoires(self):
        foo1 = Foo('ciblout')
        foo2 = Foo('remram')
        Foo.ajouter(foo1)
        Foo.ajouter(foo2)

        foos = Foo.get_two_foos()
        self.assertEqual(len(foos), 2)
        self.assertIn(foo1, foos)
        self.assertIn(foo2, foos)
Exemplo n.º 4
0
    def test_on_peut_classer(self):
        foo1 = Foo('ciblout')
        foo2 = Foo('remram')
        foo3 = Foo('remram')
        Foo.ajouter(foo1)
        Foo.ajouter(foo2)
        Foo.ajouter(foo3)
        foo1.a_vaincu(foo2)

        foos = Foo.get_sorted_list(2)

        self.assertEqual(len(foos), 2)
        self.assertEqual(foo1, foos[0])
        self.assertEqual(foo3, foos[1])
Exemplo n.º 5
0
def main():
    logger.info('Entering main ...')
    logger.debug('This is a demo for logging.')
    f = Foo()
    f.do_foo(42)
    bar.bar()
    logger.info('Leaving main ...')
Exemplo n.º 6
0
def test_foo():

    from foo import Foo
    f = Foo(10)
    assert f.n == 10
    f.incr()
    assert f.n == 11
Exemplo n.º 7
0
    def test_transaction(self):
        # test commit
        with TestDatabase.db.transaction():
            TestDatabase.db.upsert(Bar(101, 180, 33.5, 'A'))
            TestDatabase.db.upsert(Bar(102, 270, 50.33, 'B'))
        bars = TestDatabase.db.select(Bar())
        self.assertEqual(len(bars), 4)

        # test rollback on exception
        with TestDatabase.db.transaction(), \
                self.assertRaises(DatabaseIntegrityError) as cm:
            TestDatabase.db.upsert(Foo('a new foo', ))
        self.assertEqual(cm.exception.args[0], 'NOT NULL constraint failed: foo.desc')
        self.assertEqual(len(bars), 4)

        # test a forced rollback
        with TestDatabase.db.transaction() as t:
            TestDatabase.db.upsert(
                    Bar(104, 355, 99.99, 'D'))
            t.fail()
        bars = TestDatabase.db.select(Bar())
        self.assertEqual(len(bars), 4)

        # restore table to pre-test state
        with TestDatabase.db.transaction():
            TestDatabase.db.delete(Bar(101))
            TestDatabase.db.delete(Bar(102))
        bars = TestDatabase.db.select(Bar())
        self.assertEqual(len(bars), 2)
Exemplo n.º 8
0
def require_file_module():
	f = Foo()
	return f.bar()
Exemplo n.º 9
0
def test_external_module():
	return Foo().go_google()
Exemplo n.º 10
0
 def __init__(self):
     self.__foo = Foo(42, 'Fish', [0, 1, 2, 3])
Exemplo n.º 11
0
Arquivo: p0.py Projeto: xkr1997/cs188
def main():
    o = Foo('alloha')
    print(o.getName())
Exemplo n.º 12
0
"""test.py - demo of using a c++ class from within Python"""
from foo import Foo

# We'll create a Foo object with a value of 5...
f = Foo(5)

# Calling f.bar() will print a message including the value...
print('f=Foo(5)')
print('f.bar() = {}'.format(f.bar()))

# Now we'll use foobar to add a value to that stored in our Foo object, f
print("f.foobar(7) = {}".format(f.foobar(7)))

# Now we'll do the same thing - but this time demonstrate that it's a normal
# Python integer...

x = f.foobar(2)
print("Type of x; where x = f.foobar(2) is {}".format(type(x)))
Exemplo n.º 13
0
 def test_foo(self):
     foo_instance = Foo()
     self.assertEqual(foo_instance.foo(x=32), 64)
Exemplo n.º 14
0
 def test_on_peut_ajouter_des_foos(self):
     foo = Foo('ciblout')
     Foo.ajouter(foo)
     self.assertIn(foo, foo.get_liste())
Exemplo n.º 15
0
    def __init__(self):

        self.buf = [0, 0, 0, 0, 0]
        self.foo = Foo(self.buf)
        self.bar = Bar(self.buf)
Exemplo n.º 16
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')

    return ((obj1.get(), obj1.get_class_attr()),
Exemplo n.º 17
0
 def test_foo_get(self):
     foo_instance = Foo()
     self.assertIsInstance(foo_instance.foo_get(), foo.Bar)
Exemplo n.º 18
0
 def test_on_peut_renvoyer_du_hteumeuleu(self):
     foo = Foo('superFooMash')
     self.assertIsInstance(foo.__html__(), str)
Exemplo n.º 19
0
from foo import Foo

print(Foo().scope)
Exemplo n.º 20
0
 def test_clear(self):
     foo = Foo('ciclout')
     Foo.ajouter(foo)
     Foo.clear()
     self.assertEqual(Foo.get_liste(), [])
Exemplo n.º 21
0
def main():
    foo = [Foo(luca.status()), Foo(dishroom()), Foo(huh()), Foo(sports())]
    for f in foo:
        print(f.say())
Exemplo n.º 22
0
 def test_cas_foireux_pour_deux_foos(self):
     self.assertRaises(Foo.NotEnoughFoos, Foo.get_two_foos)
     Foo.ajouter(Foo('chose'))
     self.assertRaises(Foo.NotEnoughFoos, Foo.get_two_foos)
Exemplo n.º 23
0
from flask import Flask, render_template, request, redirect
from foo import Foo

app = Flask("Meta foomash")


@app.route('/')
def index():
    foos = Foo.get_two_foos()
    return render_template('index.html', foos=foos, list_foos=Foo.get_liste())


@app.route('/vote', methods=["GET"])
def vote():
    foo = Foo.get_by_name(request.args['name'])
    other = Foo.get_by_name(request.args['other'])
    foo.a_vaincu(other)
    return redirect("/")


if __name__ == "__main__":
    Foo.ajouter(Foo('ciblout'))
    Foo.ajouter(Foo('remram'))
    Foo.ajouter(Foo('lily'))

    app.debug = True
    app.run()
Exemplo n.º 24
0
 def test_get_by_name(self):
     Foo.ajouter(Foo('ciblout'))
     Foo.ajouter(Foo('remram'))
     Foo.ajouter(Foo('lily'))
     foo = Foo.get_by_name('remram')
     self.assertEqual('remram', foo.name)
Exemplo n.º 25
0
def require_sub_file_module():
	f = Foo()
	return f.yum()
Exemplo n.º 26
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
--------------------------------------------------------------
describe:
    

base_info:
    __version__ = "v.10"
    __author__ = "mingliang.gao"
    __time__ = "2020/5/23 5:07 PM"
    __mail__ = "*****@*****.**"
--------------------------------------------------------------
"""

# ------------------------------------------------------------
# usage: /usr/bin/python __init__.py.py
# ------------------------------------------------------------
from foo import Foo

foo_entry_point = Foo().entry_point()
Exemplo n.º 27
0
def what_is_love():
	f = Foo()
	return f.what_is_love(my_global_var)
Exemplo n.º 28
0
 def test_bar(self):
     foo_instance = Foo()
     self.assertEquals(foo_instance.bar(x=32), 64)
Exemplo n.º 29
0
 def test_foreign_key(self):
     with TestDatabase.db.transaction(), \
             self.assertRaises(DatabaseIntegrityError) as cm:
         # bar id 999 should not exist
         TestDatabase.db.upsert(Foo('my foo', 'a new foo', 999))
     self.assertEqual('FOREIGN KEY constraint failed', cm.exception.args[0])