author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 26 Aug 2009 14:28:22 +0200 | |
branch | stable |
changeset 3018 | e872e57e70d0 |
parent 1977 | 606923dff11b |
child 4212 | ab6573088b4a |
permissions | -rw-r--r-- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
1 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
2 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
3 |
:organization: Logilab |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
7 |
""" |
0 | 8 |
import os |
9 |
import pwd |
|
10 |
||
11 |
from logilab.common.pytest import PyTester |
|
12 |
||
13 |
def getlogin(): |
|
14 |
"""avoid usinng os.getlogin() because of strange tty / stdin problems |
|
15 |
(man 3 getlogin) |
|
16 |
Another solution would be to use $LOGNAME, $USER or $USERNAME |
|
17 |
""" |
|
18 |
return pwd.getpwuid(os.getuid())[0] |
|
19 |
||
20 |
||
21 |
def update_parser(parser): |
|
22 |
login = getlogin() |
|
23 |
parser.add_option('-r', '--rebuild-database', dest='rebuild_db', |
|
24 |
default=False, action="store_true", |
|
25 |
help="remove tmpdb and rebuilds the test database") |
|
26 |
parser.add_option('-u', '--dbuser', dest='dbuser', action='store', |
|
27 |
default=login, help="database user") |
|
28 |
parser.add_option('-w', '--dbpassword', dest='dbpassword', action='store', |
|
29 |
default=login, help="database name") |
|
30 |
parser.add_option('-n', '--dbname', dest='dbname', action='store', |
|
31 |
default=None, help="database name") |
|
32 |
parser.add_option('--euser', dest='euser', action='store', |
|
33 |
default=login, help="esuer name") |
|
34 |
parser.add_option('--epassword', dest='epassword', action='store', |
|
35 |
default=login, help="euser's password' name") |
|
36 |
return parser |
|
37 |
||
38 |
||
39 |
class CustomPyTester(PyTester): |
|
40 |
def __init__(self, cvg, options): |
|
41 |
super(CustomPyTester, self).__init__(cvg, options) |
|
42 |
if options.rebuild_db: |
|
43 |
os.unlink('tmpdb') |
|
44 |
os.unlink('tmpdb-template') |