Broke config section of test/tutorial.py out into test/config.py
authorW. Trevor King <wking@drexel.edu>
Tue, 17 Aug 2010 10:29:34 +0000 (06:29 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 17 Aug 2010 10:29:34 +0000 (06:29 -0400)
test/config.py [new file with mode: 0644]
test/tutorial.py

diff --git a/test/config.py b/test/config.py
new file mode 100644 (file)
index 0000000..0ef82cb
--- /dev/null
@@ -0,0 +1,60 @@
+# Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
+#
+# This file is part of Hooke.
+#
+# Hooke is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# Hooke is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with Hooke.  If not, see
+# <http://www.gnu.org/licenses/>.
+
+"""
+Test the commands listed in :file:`doc/tutorial.txt`.
+
+>>> import os
+>>> import os.path
+>>> from hooke.hooke import Hooke, HookeRunner
+>>> h = Hooke()
+>>> r = HookeRunner()
+>>> h = r.run_lines(h, ['set_config conditions temperature 300.0'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_config conditions temperature'])
+300.0
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['set_config conditions temperature 295.3'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_config conditions temperature'])
+295.3
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['print_config'])  # doctest: +ELLIPSIS
+# Default environmental conditions in case they are not specified in
+# the force curve data.  Configuration options in this section are
+# available to every plugin.
+[conditions]
+# Temperature in Kelvin
+temperature = 295.3
+<BLANKLINE>
+...
+>>> config_already_exists = os.path.exists('myconfig.cfg')
+>>> config_already_exists
+False
+>>> h = r.run_lines(h, ['save_config --output myconfig.cfg'])
+Success
+<BLANKLINE>
+>>> os.path.isfile('myconfig.cfg')
+True
+>>> if config_already_exists == False:
+...     os.remove('myconfig.cfg')
+"""
index 967cda8498f57afd472b2e790ff1747b34f02bdd..d35269771553015451d23e1d77c93af1df318f7d 100644 (file)
@@ -249,30 +249,5 @@ Success
 
 *Configuring Hooke*
 
->>> h = r.run_lines(h, ['set_config conditions temperature 300.0'])
-Success
-<BLANKLINE>
->>> h = r.run_lines(h, ['get_config conditions temperature'])
-300.0
-Success
-<BLANKLINE>
->>> h = r.run_lines(h, ['set_config conditions temperature 295.3'])
-Success
-<BLANKLINE>
->>> h = r.run_lines(h, ['get_config conditions temperature'])
-295.3
-Success
-<BLANKLINE>
->>> h = r.run_lines(h, ['print_config'])  # doctest: +ELLIPSIS
-# Default environmental conditions in case they are not specified in
-# the force curve data.  Configuration options in this section are
-# available to every plugin.
-[conditions]
-# Temperature in Kelvin
-temperature = 295.3
-<BLANKLINE>
-...
->>> h = r.run_lines(h, ['save_config'])
-Success
-<BLANKLINE>
+See :file:`config.py`.
 """