
from pip.status_codes import ERROR
from tests.lib.configuration_helpers import kinds, ConfigurationFileIOMixin


def test_no_options_passed_should_error(script):
    result = script.pip('config', expect_error=True)
    assert result.returncode == ERROR


class TestBasicLoading(ConfigurationFileIOMixin):

    def test_reads_user_file(self, script):
        contents = """
            [test]
            hello = 1
        """

        with self.patched_file(kinds.USER, contents):
            result = script.pip("config", "--list")

        assert "test.hello = 1" in result.stdout


import pytest
import textwrap

from pip.status_codes import ERROR
from tests.lib.configuration_helpers import kinds, ConfigurationFileIOMixin


def test_no_options_passed_should_error(script):
    result = script.pip('config', expect_error=True)
    assert result.returncode == ERROR


class TestBasicLoading(ConfigurationFileIOMixin):

    @pytest.mark.skip("Can't modify underlying file for any mode")
    def test_reads_file_appropriately(self, script):
        contents = """
            [test]
            hello = 1
        """

        with self.patched_file(kinds.USER, contents):
            result = script.pip("config", "list")

        assert "test.hello=1" in result.stdout

    def test_modification_pipeline(self, script):
        script.pip(
            "config", "get", "test.blah", expect_error=True
        )
        script.pip("config", "set", "test.blah", "1")

        result4 = script.pip("config", "get", "test.blah")
        assert result4.stdout.strip() == "1"

    def test_listing_is_correct(self, script):
        script.pip("config", "set", "test.listing-beta", "2")
        script.pip("config", "set", "test.listing-alpha", "1")
        script.pip("config", "set", "test.listing-gamma", "3")

        result = script.pip("config", "list")

        lines = list(filter(
            lambda x: x.startswith("test.listing-"),
            result.stdout.splitlines()
        ))

        expected = """
            test.listing-alpha='1'
            test.listing-beta='2'
            test.listing-gamma='3'
        """

        assert lines == textwrap.dedent(expected).strip().splitlines()

Add basic tests for configuration
Add basic tests for configuration

+ 
+ import pytest
+ import textwrap
  
  from pip.status_codes import ERROR
  from tests.lib.configuration_helpers import kinds, ConfigurationFileIOMixin
  
  
  def test_no_options_passed_should_error(script):
      result = script.pip('config', expect_error=True)
      assert result.returncode == ERROR
  
  
  class TestBasicLoading(ConfigurationFileIOMixin):
  
+     @pytest.mark.skip("Can't modify underlying file for any mode")
-     def test_reads_user_file(self, script):
+     def test_reads_file_appropriately(self, script):
          contents = """
              [test]
              hello = 1
          """
  
          with self.patched_file(kinds.USER, contents):
-             result = script.pip("config", "--list")
+             result = script.pip("config", "list")
  
-         assert "test.hello = 1" in result.stdout
+         assert "test.hello=1" in result.stdout
  
+     def test_modification_pipeline(self, script):
+         script.pip(
+             "config", "get", "test.blah", expect_error=True
+         )
+         script.pip("config", "set", "test.blah", "1")
+ 
+         result4 = script.pip("config", "get", "test.blah")
+         assert result4.stdout.strip() == "1"
+ 
+     def test_listing_is_correct(self, script):
+         script.pip("config", "set", "test.listing-beta", "2")
+         script.pip("config", "set", "test.listing-alpha", "1")
+         script.pip("config", "set", "test.listing-gamma", "3")
+ 
+         result = script.pip("config", "list")
+ 
+         lines = list(filter(
+             lambda x: x.startswith("test.listing-"),
+             result.stdout.splitlines()
+         ))
+ 
+         expected = """
+             test.listing-alpha='1'
+             test.listing-beta='2'
+             test.listing-gamma='3'
+         """
+ 
+         assert lines == textwrap.dedent(expected).strip().splitlines()
+ 
Add basic tests for configuration
## Code Before:

from pip.status_codes import ERROR
from tests.lib.configuration_helpers import kinds, ConfigurationFileIOMixin


def test_no_options_passed_should_error(script):
    result = script.pip('config', expect_error=True)
    assert result.returncode == ERROR


class TestBasicLoading(ConfigurationFileIOMixin):

    def test_reads_user_file(self, script):
        contents = """
            [test]
            hello = 1
        """

        with self.patched_file(kinds.USER, contents):
            result = script.pip("config", "--list")

        assert "test.hello = 1" in result.stdout

## Instruction:
Add basic tests for configuration
## Code After:

import pytest
import textwrap

from pip.status_codes import ERROR
from tests.lib.configuration_helpers import kinds, ConfigurationFileIOMixin


def test_no_options_passed_should_error(script):
    result = script.pip('config', expect_error=True)
    assert result.returncode == ERROR


class TestBasicLoading(ConfigurationFileIOMixin):

    @pytest.mark.skip("Can't modify underlying file for any mode")
    def test_reads_file_appropriately(self, script):
        contents = """
            [test]
            hello = 1
        """

        with self.patched_file(kinds.USER, contents):
            result = script.pip("config", "list")

        assert "test.hello=1" in result.stdout

    def test_modification_pipeline(self, script):
        script.pip(
            "config", "get", "test.blah", expect_error=True
        )
        script.pip("config", "set", "test.blah", "1")

        result4 = script.pip("config", "get", "test.blah")
        assert result4.stdout.strip() == "1"

    def test_listing_is_correct(self, script):
        script.pip("config", "set", "test.listing-beta", "2")
        script.pip("config", "set", "test.listing-alpha", "1")
        script.pip("config", "set", "test.listing-gamma", "3")

        result = script.pip("config", "list")

        lines = list(filter(
            lambda x: x.startswith("test.listing-"),
            result.stdout.splitlines()
        ))

        expected = """
            test.listing-alpha='1'
            test.listing-beta='2'
            test.listing-gamma='3'
        """

        assert lines == textwrap.dedent(expected).strip().splitlines()
