PY-13760 BDD: rerun for failed tests doesn't work for tests on different disk
authorIlya.Kazakevich <Ilya.Kazakevich@jetbrains.com>
Fri, 29 Aug 2014 17:48:44 +0000 (21:48 +0400)
committerIlya.Kazakevich <Ilya.Kazakevich@jetbrains.com>
Fri, 29 Aug 2014 17:48:44 +0000 (21:48 +0400)
python/helpers/pycharm/_bdd_utils.py
python/helpers/pycharm/behave_runner.py
python/helpers/pycharm/lettuce_runner.py

index 300feb286051cecde2a79002df79eec3499cb742..eea1bebf16546a1a8d9a2b0b886b6342261c9b9b 100644 (file)
@@ -15,6 +15,20 @@ import tcmessages
 __author__ = 'Ilya.Kazakevich'
 
 
+def fix_win_drive(feature_path):
+    """
+    Workaround to fix issues like http://bugs.python.org/issue7195 on windows.
+    Pass feature dir or file path as argument.
+    This function does nothing on non-windows platforms, so it could be run safely.
+
+    :param feature_path: path to feature (c:/fe.feature or /my/features)
+    """
+    current_disk = (os.path.splitdrive(os.getcwd()))[0]
+    feature_disk = (os.path.splitdrive(feature_path))[0]
+    if current_disk and feature_disk and current_disk != feature_disk:
+        os.chdir(feature_disk)
+
+
 def get_path_by_args(arguments):
     """
     :type arguments list
index 0ad83137adb62cf82a99177ec4a991631a191c1e..2ec649ea7c1d7de07279052f10227d2af9d2eddb 100644 (file)
@@ -228,6 +228,8 @@ if __name__ == "__main__":
         pass
 
     command_args = list(filter(None, sys.argv[1:]))
+    if command_args:
+        _bdd_utils.fix_win_drive(command_args[0])
     my_config = configuration.Configuration(command_args=command_args)
     formatters.register_as(_Null, "com.intellij.python.null")
     my_config.format = ["com.intellij.python.null"]  # To prevent output to stdout
index 3cd112540e5f5bf65b78918df67702d19c6a8aac..f0a4b5dbb873fe9d38565eb3d82f0b34adb3a8b0 100644 (file)
@@ -109,4 +109,5 @@ class _LettuceRunner(_bdd_utils.BddRunner):
 
 if __name__ == "__main__":
     (base_dir, what_to_run) = _bdd_utils.get_path_by_args(sys.argv)
+    _bdd_utils.fix_win_drive(what_to_run)
     _LettuceRunner(base_dir, what_to_run).run()
\ No newline at end of file