import unittest
import tempfile
import os
from shellpython.helpers import Dir


class TestDirectory(unittest.TestCase):

    def test_relative_dirs(self):
        cur_dir = os.path.split(__file__)[0]

        with Dir(os.path.join(cur_dir, 'data')):
            self.assertEqual(os.path.join(cur_dir, 'data'), os.getcwd())
            with Dir(os.path.join('locator')):
                self.assertEqual(os.path.join(cur_dir, 'data', 'locator'), os.getcwd())

    def test_absolute_dirs(self):
        with Dir(tempfile.gettempdir()):
            self.assertEqual(tempfile.gettempdir(), os.getcwd())

@@ -35,16 +35,36 @@
 port os%0A
+from os import path%0A
 from she
@@ -190,21 +190,33 @@
 r = 
-os.path.split
+path.dirname(path.abspath
 (__f
@@ -225,11 +225,9 @@
 e__)
-%5B0%5D
+)
 %0A%0A  
@@ -233,35 +233,32 @@
        with Dir(
-os.
 path.join(cur_di
@@ -291,35 +291,32 @@
 elf.assertEqual(
-os.
 path.join(cur_di
@@ -361,19 +361,16 @@
 ith Dir(
-os.
 path.joi
@@ -417,19 +417,16 @@
 rtEqual(
-os.
 path.joi

Fix directory tests, __file__ may return relative path and now it is taken into consideration