annotate MoinMoin/_tests/maketestwiki.py @ 3910:6fbfffffc4d1

Insert moins path more aggressively into sys.path to win the race against py.test, do insertions less often in make_test_wiki
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Thu, 31 Jul 2008 14:17:19 +0200
parents 48b95abf3994
children 68f8bea727e5
rev   line source
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
2 """
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
3 MoinMoin - make a test wiki
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
4
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
5 Usage:
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
6
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
7 maketestwiki.py
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
8
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
9 @copyright: 2005 by Thomas Waldmann
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
10 @license: GNU GPL, see COPYING for details.
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
11 """
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
12
2174
f5f4dbbd0c51 added tarfile.py from py 2.5.1 (backported to work with py 2.3/2.4), fix imports to use it for tests/backup (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2006
diff changeset
13 import os, sys, shutil, errno
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
14
2006
1339d6fdc4ff Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
15 filename = globals().get("__file__") or sys.argv[0]
1339d6fdc4ff Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
16 moinpath = os.path.abspath(os.path.join(os.path.dirname(filename), os.pardir, os.pardir))
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
17
2174
f5f4dbbd0c51 added tarfile.py from py 2.5.1 (backported to work with py 2.3/2.4), fix imports to use it for tests/backup (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2006
diff changeset
18 from MoinMoin.support import tarfile
f5f4dbbd0c51 added tarfile.py from py 2.5.1 (backported to work with py 2.3/2.4), fix imports to use it for tests/backup (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2006
diff changeset
19
2006
1339d6fdc4ff Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
20 WIKI = os.path.abspath(os.path.join(moinpath, 'tests', 'wiki'))
1339d6fdc4ff Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
21 SHARE = os.path.abspath(os.path.join(moinpath, 'wiki'))
1339d6fdc4ff Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
22
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
23
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
24 def removeTestWiki():
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
25 print 'removing old wiki ...'
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
26 for dir in ['data', 'underlay']:
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
27 try:
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
28 shutil.rmtree(os.path.join(WIKI, dir))
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
29 except OSError, err:
348
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
30 if not (err.errno == errno.ENOENT or
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
31 (err.errno == 3 and os.name == 'nt')):
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
32 raise
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
33
2006
1339d6fdc4ff Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
34
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
35 def copyData():
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
36 print 'copying data ...'
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
37 src = os.path.join(SHARE, 'data')
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
38 dst = os.path.join(WIKI, 'data')
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
39 shutil.copytree(src, dst)
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
40
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
41
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
42 def untarUnderlay():
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
43 print 'untaring underlay ...'
3392
48b95abf3994 fix tests: need to untar underlay.tar not underlay.tar.bz2
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2174
diff changeset
44 tar = tarfile.open(os.path.join(SHARE, 'underlay.tar'))
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
45 for member in tar:
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
46 tar.extract(member, WIKI)
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
47 tar.close()
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
48
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
49
2006
1339d6fdc4ff Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
50 def run(skip_if_existing=False):
348
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
51 try:
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
52 os.makedirs(WIKI)
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
53 except OSError, e:
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
54 if e.errno != errno.EEXIST:
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
55 raise
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
56
2006
1339d6fdc4ff Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
57 if skip_if_existing and os.path.exists(os.path.join(WIKI, 'data')):
1339d6fdc4ff Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
58 return
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
59 removeTestWiki()
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
60 copyData()
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
61 untarUnderlay()
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
62
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
63 if __name__ == '__main__':
3910
6fbfffffc4d1 Insert moins path more aggressively into sys.path to win the race against py.test, do insertions less often in make_test_wiki
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 3392
diff changeset
64 sys.path.insert(0, moinpath)
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
65 run()
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
66