import os
import errno
import subprocess
import nose.tools as nt

test_rst_fname = 'tests/tutorial.rst.ref'
ref_ipynb_fname = 'tests/tutorial.ipynb.ref'
test_generate_ipynb_fname = 'tests/tutorial.ipynb'


def clean_dir():
    "Remove generated ipynb file created during conversion"
    try:
        os.unlink(test_generate_ipynb_fname)
    except OSError, e:
        if e.errno != errno.ENOENT:
            raise


@nt.with_setup(clean_dir, clean_dir)
def test_command_line():
    with open(ref_ipynb_fname, 'rb') as f:
        ref_output = f.read()
    output = subprocess.check_output(['./rst2ipynb.py', test_rst_fname])
    nt.assert_equal(ref_output, output)

@@ -16,16 +16,31 @@
 t errno%0A
+import os.path%0A
 import s
@@ -83,39 +83,55 @@
 est_rst_fname = 
+os.path.join(
 'tests
-/
+', '
 tutorial.rst.ref
@@ -131,16 +131,17 @@
 rst.ref'
+)
 %0Aref_ipy
@@ -143,39 +143,55 @@
 f_ipynb_fname = 
+os.path.join(
 'tests
-/
+', '
 tutorial.ipynb.r
@@ -193,16 +193,17 @@
 ynb.ref'
+)
 %0Atest_ge
@@ -227,15 +227,31 @@
 e = 
+os.path.join(
 'tests
-/
+', '
 tuto
@@ -261,16 +261,17 @@
 l.ipynb'
+)
 %0A%0A%0Adef c

clean up