Skip to content

back to SWE-Agent summary

SWE-Agent: fabric

Failed to run pytests for test tests

ImportError while loading conftest '/testbed/tests/conftest.py'.
tests/conftest.py:10: in <module>
    from fabric.testing.fixtures import client, remote, sftp, sftp_objs, transfer
fabric/__init__.py:3: in <module>
    from .connection import Config, Connection
fabric/connection.py:17: in <module>
    class Connection(Context):
fabric/connection.py:443: in Connection
    @opens
E   NameError: name 'opens' is not defined

Patch diff

diff --git a/fabric/connection.py b/fabric/connection.py
index b00bf937..e806a426 100644
--- a/fabric/connection.py
+++ b/fabric/connection.py
@@ -125,7 +125,32 @@ class Connection(Context):

         .. versionadded:: 2.4
         """
-        pass
+        config = Config()
+        # Map Fabric 1 env vars to Fabric 2 config
+        if 'user' in env:
+            config['user'] = env['user']
+        if 'port' in env:
+            config['port'] = env['port']
+        if 'host_string' in env:
+            host = env['host_string']
+        else:
+            raise InvalidV1Env("Missing required 'host_string' in env")
+        if 'key_filename' in env:
+            config['connect_kwargs'] = {'key_filename': env['key_filename']}
+        if 'password' in env:
+            config['connect_kwargs'] = config.get('connect_kwargs', {})
+            config['connect_kwargs']['password'] = env['password']
+        if 'gateway' in env:
+            config['gateway'] = env['gateway']
+        if 'forward_agent' in env:
+            config['forward_agent'] = env['forward_agent']
+        if 'connect_timeout' in env:
+            config['timeouts'] = {'connect': env['connect_timeout']}
+        
+        # Update with any additional kwargs
+        config.update(kwargs)
+        
+        return cls(host, config=config)

     def __init__(self, host, user=None, port=None, config=None, gateway=None, forward_agent=None, connect_timeout=None, connect_kwargs=None, inline_ssh_env=None):
         """
@@ -647,4 +672,4 @@ class Connection(Context):

         .. versionadded:: 2.0
         """
-        pass
\ No newline at end of file
+        pass