import unittest
import sys
import os
import tempfile
import shutil

plugin_root = os.path.realpath(os.path.dirname(os.path.dirname(__file__)))
sys.path.append(os.path.join(plugin_root, 'lib'))

import main

join = os.path.join

class TestFileSystem(unittest.TestCase):

    def test_find_relative_same_dir(self):
        temp_dir = tempfile.mkdtemp(prefix='node-require-test')
        try:
            open(temp_dir + '/required.js', 'a').close()
            result = main.find_relative(temp_dir + '/main.js', './required')
            expected = temp_dir + '/required.js'
            self.assertEqual(expected, result)
        except Exception as err:
            self.fail(err)
            shutil.rmtree(temp_dir)

    def test_find_relative_nested_dir_below(self):
        temp_dir = tempfile.mkdtemp(prefix='node-require-test')
        try:
            nested_dir = temp_dir + '/foo/bar/baz'
            os.makedirs(nested_dir)
            open(nested_dir + '/required.js', 'a').close()
            result = main.find_relative(temp_dir + '/main.js', './foo/bar/baz/required')
            expected = temp_dir + '/foo/bar/baz/required.js'
            self.assertEqual(expected, result)
        except Exception as err:
            self.fail(err)
            shutil.rmtree(temp_dir)

if __name__ == '__main__':
    unittest.main()

@@ -231,22 +231,23 @@
 ass 
-TestFileSystem
+RelativeRequire
 (uni
@@ -510,32 +510,33 @@
 , './required')%0A
+%0A
             expe
@@ -607,32 +607,33 @@
 pected, result)%0A
+%0A
         except E
@@ -1076,16 +1076,17 @@
 uired')%0A
+%0A
         
@@ -1130,32 +1130,32 @@
 az/required.js'%0A
-
             self
@@ -1185,16 +1185,519 @@
 result)%0A
+%0A        except Exception as err:%0A            self.fail(err)%0A            shutil.rmtree(temp_dir)%0A%0A    def test_find_relative_nested_dir_above(self):%0A        temp_dir = tempfile.mkdtemp(prefix='node-require-test')%0A        try:%0A            open(temp_dir + '/required.js', 'a').close()%0A            current_file = temp_dir + '/foo/main.js'%0A            result = main.find_relative(current_file, '../required')%0A%0A            expected = temp_dir + '/required.js'%0A            self.assertEqual(expected, result)%0A%0A
         

Add test for directory above