test/data/vclamp_jpk/README: Document sample versions
[hooke.git] / test / export_block.py
1 # Copyright (C) 2010-2012 W. Trevor King <wking@tremily.us>
2 #
3 # This file is part of Hooke.
4 #
5 # Hooke is free software: you can redistribute it and/or modify it under the
6 # terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option) any
8 # later version.
9 #
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
13 # details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with Hooke.  If not, see <http://www.gnu.org/licenses/>.
17
18 """
19 >>> import os
20 >>> import os.path
21 >>> from uuid import uuid4
22 >>> from hooke.hooke import Hooke, HookeRunner
23
24 >>> h = Hooke()
25 >>> r = HookeRunner()
26 >>> h = r.run_lines(h, ['load_playlist test/data/test']) # doctest: +ELLIPSIS
27 <FilePlaylist test.hkp>
28 Success
29 <BLANKLINE>
30 >>> file_name = '%s.dat' % uuid4()
31 >>> export_already_exists = os.path.exists(file_name)
32 >>> export_already_exists
33 False
34 >>> h = r.run_lines(h, ['export_block --output %s' % file_name])
35 Success
36 <BLANKLINE>
37 >>> with open(file_name, 'r') as f:
38 ...     lines = f.readlines()
39 >>> if export_already_exists == False:
40 ...    os.remove(file_name)
41 >>> len(lines)
42 2049
43 >>> print(''.join(lines[:5]).rstrip())
44 ... # doctest: +ELLIPSIS, +REPORT_UDIFF +NORMALIZE_WHITESPACE
45 # z piezo (m)  deflection (m)
46 -1.519...e-07  9.094...e-08
47 -1.513...e-07  9.130...e-08
48 -1.513...e-07  9.157...e-08
49 -1.507...e-07  9.189...e-08
50 """