import pytest

from juju.controller import Controller
from juju.juju import Juju
from .. import base


@base.bootstrapped
@pytest.mark.asyncio
async def test_get_controllers(event_loop):
    async with base.CleanController() as controller:
        j = Juju()

        controllers = j.get_controllers()
        assert isinstance(controllers, dict)
        assert len(controllers) >= 1
        assert controller.controller_name in controllers

        cc = await j.get_controller(controller.controller_name)
        assert isinstance(cc, Controller)
        assert controller.connection().endpoint == cc.connection().endpoint

import pytest

from juju.controller import Controller
from juju.juju import Juju
from .. import base


@base.bootstrapped
@pytest.mark.asyncio
async def test_get_controllers(event_loop):
    async with base.CleanController() as controller:
        j = Juju()

        controllers = j.get_controllers()
        assert isinstance(controllers, dict)
        assert len(controllers) >= 1
        assert controller.controller_name in controllers

        cc = await j.get_controller(controller.controller_name)
        assert isinstance(cc, Controller)
        assert controller.connection().endpoint == cc.connection().endpoint
        await cc.disconnect()

Make sure to disconnect the extra connection before finishing the test
Make sure to disconnect the extra connection before finishing the test

  import pytest
  
  from juju.controller import Controller
  from juju.juju import Juju
  from .. import base
  
  
  @base.bootstrapped
  @pytest.mark.asyncio
  async def test_get_controllers(event_loop):
      async with base.CleanController() as controller:
          j = Juju()
  
          controllers = j.get_controllers()
          assert isinstance(controllers, dict)
          assert len(controllers) >= 1
          assert controller.controller_name in controllers
  
          cc = await j.get_controller(controller.controller_name)
          assert isinstance(cc, Controller)
          assert controller.connection().endpoint == cc.connection().endpoint
+         await cc.disconnect()
  
Make sure to disconnect the extra connection before finishing the test
## Code Before:
import pytest

from juju.controller import Controller
from juju.juju import Juju
from .. import base


@base.bootstrapped
@pytest.mark.asyncio
async def test_get_controllers(event_loop):
    async with base.CleanController() as controller:
        j = Juju()

        controllers = j.get_controllers()
        assert isinstance(controllers, dict)
        assert len(controllers) >= 1
        assert controller.controller_name in controllers

        cc = await j.get_controller(controller.controller_name)
        assert isinstance(cc, Controller)
        assert controller.connection().endpoint == cc.connection().endpoint

## Instruction:
Make sure to disconnect the extra connection before finishing the test
## Code After:
import pytest

from juju.controller import Controller
from juju.juju import Juju
from .. import base


@base.bootstrapped
@pytest.mark.asyncio
async def test_get_controllers(event_loop):
    async with base.CleanController() as controller:
        j = Juju()

        controllers = j.get_controllers()
        assert isinstance(controllers, dict)
        assert len(controllers) >= 1
        assert controller.controller_name in controllers

        cc = await j.get_controller(controller.controller_name)
        assert isinstance(cc, Controller)
        assert controller.connection().endpoint == cc.connection().endpoint
        await cc.disconnect()
