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())

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


class TestDirectory(unittest.TestCase):

    def test_relative_dirs(self):
        cur_dir = path.dirname(path.abspath(__file__))

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

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

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

  import unittest
  import tempfile
  import os
+ from os import path
  from shellpython.helpers import Dir
  
  
  class TestDirectory(unittest.TestCase):
  
      def test_relative_dirs(self):
-         cur_dir = os.path.split(__file__)[0]
+         cur_dir = path.dirname(path.abspath(__file__))
  
-         with Dir(os.path.join(cur_dir, 'data')):
+         with Dir(path.join(cur_dir, 'data')):
-             self.assertEqual(os.path.join(cur_dir, 'data'), os.getcwd())
+             self.assertEqual(path.join(cur_dir, 'data'), os.getcwd())
-             with Dir(os.path.join('locator')):
+             with Dir(path.join('locator')):
-                 self.assertEqual(os.path.join(cur_dir, 'data', 'locator'), os.getcwd())
+                 self.assertEqual(path.join(cur_dir, 'data', 'locator'), os.getcwd())
  
      def test_absolute_dirs(self):
          with Dir(tempfile.gettempdir()):
              self.assertEqual(tempfile.gettempdir(), os.getcwd())
  
Fix directory tests, __file__ may return relative path and now it is taken into consideration
## Code Before:
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())

## Instruction:
Fix directory tests, __file__ may return relative path and now it is taken into consideration
## Code After:
import unittest
import tempfile
import os
from os import path
from shellpython.helpers import Dir


class TestDirectory(unittest.TestCase):

    def test_relative_dirs(self):
        cur_dir = path.dirname(path.abspath(__file__))

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

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