Repository: pallets/click
Pull request #1492 (2020-03-09 14:40:42)

deprecate old param callback style
This has been emitting a warning since 2.0. Turn it into a deprecation warning to be removed in 8.0.


Patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index 8bc1f6b..b1edaac 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,18 +1,5 @@
 .. currentmodule:: click
 
-Version 8.0
------------
-
-Unreleased
-
--   Adds a repr to Command, showing the command name for friendlier
-    debugging. :issue:`1267`, :pr:`1295`
--   Add support for distinguishing the source of a command line
-    parameter. :issue:`1264`, :pr:`1329`
--   Add an optional parameter to ``ProgressBar.update`` to set the
-    ``current_item``. :issue:`1226`, :pr:`1332`
-
-
 Version 7.1
 -----------
 
@@ -79,6 +66,9 @@ Unreleased
 -   Add completion support for Fish shell. :pr:`1423`
 -   Decoding bytes option values falls back to UTF-8 in more cases.
     :pr:`1468`
+-   Make the warning about old 2-arg parameter callbacks a deprecation
+    warning, to be removed in 8.0. This has been a warning since Click
+    2.0. :pr:`1492`
 
 
 Version 7.0
@@ -469,16 +459,15 @@ Version 3.0
 
 Released 2014-08-12, codename "clonk clonk"
 
--   Formatter now no longer attempts to accommodate for terminals
-    smaller than 50 characters. If that happens it just assumes a
-    minimal width.
+-   Formatter now no longer attempts to accomodate for terminals smaller
+    than 50 characters. If that happens it just assumes a minimal width.
 -   Added a way to not swallow exceptions in the test system.
 -   Added better support for colors with pagers and ways to override the
     autodetection.
 -   The CLI runner's result object now has a traceback attached.
 -   Improved automatic short help detection to work better with dots
     that do not terminate sentences.
--   When defining options without actual valid option strings now,
+-   When definining options without actual valid option strings now,
     Click will give an error message instead of silently passing. This
     should catch situations where users wanted to created arguments
     instead of options.
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
deleted file mode 100644
index f4ba197..0000000
--- a/CODE_OF_CONDUCT.md
+++ /dev/null
@@ -1,76 +0,0 @@
-# Contributor Covenant Code of Conduct
-
-## Our Pledge
-
-In the interest of fostering an open and welcoming environment, we as
-contributors and maintainers pledge to making participation in our project and
-our community a harassment-free experience for everyone, regardless of age, body
-size, disability, ethnicity, sex characteristics, gender identity and expression,
-level of experience, education, socio-economic status, nationality, personal
-appearance, race, religion, or sexual identity and orientation.
-
-## Our Standards
-
-Examples of behavior that contributes to creating a positive environment
-include:
-
-* Using welcoming and inclusive language
-* Being respectful of differing viewpoints and experiences
-* Gracefully accepting constructive criticism
-* Focusing on what is best for the community
-* Showing empathy towards other community members
-
-Examples of unacceptable behavior by participants include:
-
-* The use of sexualized language or imagery and unwelcome sexual attention or
- advances
-* Trolling, insulting/derogatory comments, and personal or political attacks
-* Public or private harassment
-* Publishing others' private information, such as a physical or electronic
- address, without explicit permission
-* Other conduct which could reasonably be considered inappropriate in a
- professional setting
-
-## Our Responsibilities
-
-Project maintainers are responsible for clarifying the standards of acceptable
-behavior and are expected to take appropriate and fair corrective action in
-response to any instances of unacceptable behavior.
-
-Project maintainers have the right and responsibility to remove, edit, or
-reject comments, commits, code, wiki edits, issues, and other contributions
-that are not aligned to this Code of Conduct, or to ban temporarily or
-permanently any contributor for other behaviors that they deem inappropriate,
-threatening, offensive, or harmful.
-
-## Scope
-
-This Code of Conduct applies both within project spaces and in public spaces
-when an individual is representing the project or its community. Examples of
-representing a project or community include using an official project e-mail
-address, posting via an official social media account, or acting as an appointed
-representative at an online or offline event. Representation of a project may be
-further defined and clarified by project maintainers.
-
-## Enforcement
-
-Instances of abusive, harassing, or otherwise unacceptable behavior may be
-reported by contacting the project team at report@palletsprojects.com. All
-complaints will be reviewed and investigated and will result in a response that
-is deemed necessary and appropriate to the circumstances. The project team is
-obligated to maintain confidentiality with regard to the reporter of an incident.
-Further details of specific enforcement policies may be posted separately.
-
-Project maintainers who do not follow or enforce the Code of Conduct in good
-faith may face temporary or permanent repercussions as determined by other
-members of the project's leadership.
-
-## Attribution
-
-This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
-available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
-
-[homepage]: https://www.contributor-covenant.org
-
-For answers to common questions about this code of conduct, see
-https://www.contributor-covenant.org/faq
diff --git a/docs/advanced.rst b/docs/advanced.rst
index 6278893..f2569fe 100644
--- a/docs/advanced.rst
+++ b/docs/advanced.rst
@@ -379,30 +379,3 @@ do.  However if you do use this for threading you need to be very careful
 as the vast majority of the context is not thread safe!  You are only
 allowed to read from the context, but not to perform any modifications on
 it.
-
-
-Detecting the Source of a Parameter
------------------------------------
-
-In some situations it's helpful to understand whether or not an option
-or parameter came from the command line, the environment, the default
-value, or the default_map. The :meth:`Context.get_parameter_source`
-method can be used to find this out.
-
-.. click:example::
-
-    @click.command()
-    @click.argument('port', nargs=1, default=8080, envvar="PORT")
-    @click.pass_context
-    def cli(ctx, port):
-        source = ctx.get_parameter_source("port")
-        click.echo("Port came from {}".format(source))
-
-.. click:run::
-
-    invoke(cli, prog_name='cli', args=['8080'])
-    println()
-    invoke(cli, prog_name='cli', args=[], env={"PORT": "8080"})
-    println()
-    invoke(cli, prog_name='cli', args=[])
-    println()
diff --git a/docs/commands.rst b/docs/commands.rst
index da26ac0..c32e917 100644
--- a/docs/commands.rst
+++ b/docs/commands.rst
@@ -202,7 +202,7 @@ A custom multi command just needs to implement a list and load method:
         def list_commands(self, ctx):
             rv = []
             for filename in os.listdir(plugin_folder):
-                if filename.endswith('.py') and filename != '__init__.py':
+                if filename.endswith('.py'):
                     rv.append(filename[:-3])
             rv.sort()
             return rv
@@ -287,7 +287,7 @@ Multi Command Chaining
 Sometimes it is useful to be allowed to invoke more than one subcommand in
 one go.  For instance if you have installed a setuptools package before
 you might be familiar with the ``setup.py sdist bdist_wheel upload``
-command chain which invokes ``sdist`` before ``bdist_wheel`` before
+command chain which invokes ``dist`` before ``bdist_wheel`` before
 ``upload``.  Starting with Click 3.0 this is very simple to implement.
 All you have to do is to pass ``chain=True`` to your multicommand:
 
diff --git a/docs/quickstart.rst b/docs/quickstart.rst
index c8cb2d9..3644509 100644
--- a/docs/quickstart.rst
+++ b/docs/quickstart.rst
@@ -32,7 +32,12 @@ install separate copies of Python, but it does provide a clever way to
 keep different project environments isolated.  Let's see how virtualenv
 works.
 
-If you are on Mac OS X or Linux::
+If you are on Mac OS X or Linux, chances are that one of the following two
+commands will work for you::
+
+    $ sudo easy_install virtualenv
+
+or even better::
 
     $ pip install virtualenv --user
 
diff --git a/docs/setuptools.rst b/docs/setuptools.rst
index 62999d7..870591a 100644
--- a/docs/setuptools.rst
+++ b/docs/setuptools.rst
@@ -43,9 +43,7 @@ Introduction
 To bundle your script with setuptools, all you need is the script in a
 Python package and a ``setup.py`` file.
 
-Imagine this directory structure:
-
-.. code-block:: text
+Imagine this directory structure::
 
     yourscript.py
     setup.py
@@ -61,24 +59,21 @@ Contents of ``yourscript.py``:
         """Example script."""
         click.echo('Hello World!')
 
-Contents of ``setup.py``:
-
-.. code-block:: python
+Contents of ``setup.py``::
 
     from setuptools import setup
 
     setup(
         name='yourscript',
-        version='0.1.0',
+        version='0.1',
         py_modules=['yourscript'],
         install_requires=[
             'Click',
         ],
-        entry_points={
-            'console_scripts': [
-                'yourscript = yourscript:cli',
-            ],
-        },
+        entry_points='''
+            [console_scripts]
+            yourscript=yourscript:cli
+        ''',
     )
 
 The magic is in the ``entry_points`` parameter.  Below
@@ -93,9 +88,7 @@ Testing The Script
 ------------------
 
 To test the script, you can make a new virtualenv and then install your
-package:
-
-.. code-block:: console
+package::
 
     $ virtualenv venv
     $ . venv/bin/activate
@@ -112,42 +105,35 @@ Scripts in Packages
 
 If your script is growing and you want to switch over to your script being
 contained in a Python package the changes necessary are minimal.  Let's
-assume your directory structure changed to this:
+assume your directory structure changed to this::
 
-.. code-block:: text
-
-    project/
-        yourpackage/
+    yourpackage/
+        __init__.py
+        main.py
+        utils.py
+        scripts/
             __init__.py
-            main.py
-            utils.py
-            scripts/
-                __init__.py
-                yourscript.py
-        setup.py
+            yourscript.py
 
 In this case instead of using ``py_modules`` in your ``setup.py`` file you
 can use ``packages`` and the automatic package finding support of
 setuptools.  In addition to that it's also recommended to include other
 package data.
 
-These would be the modified contents of ``setup.py``:
-
-.. code-block:: python
+These would be the modified contents of ``setup.py``::
 
     from setuptools import setup, find_packages
 
     setup(
         name='yourpackage',
-        version='0.1.0',
+        version='0.1',
         packages=find_packages(),
         include_package_data=True,
         install_requires=[
             'Click',
         ],
-        entry_points={
-            'console_scripts': [
-                'yourscript = yourpackage.scripts.yourscript:cli',
-            ],
-        },
+        entry_points='''
+            [console_scripts]
+            yourscript=yourpackage.scripts.yourscript:cli
+        ''',
     )
diff --git a/examples/aliases/aliases.py b/examples/aliases/aliases.py
index e7f850d..250c646 100644
--- a/examples/aliases/aliases.py
+++ b/examples/aliases/aliases.py
@@ -53,7 +53,7 @@ class AliasedGroup(click.Group):
         # will create the config object is missing.
         cfg = ctx.ensure_object(Config)
 
-        # Step three: look up an explicit command alias in the config
+        # Step three: lookup an explicit command aliase in the config
         if cmd_name in cfg.aliases:
             actual_cmd = cfg.aliases[cmd_name]
             return click.Group.get_command(self, ctx, actual_cmd)
diff --git a/src/click/_bashcomplete.py b/src/click/_bashcomplete.py
index cbabd8d..8bca244 100644
--- a/src/click/_bashcomplete.py
+++ b/src/click/_bashcomplete.py
@@ -160,7 +160,7 @@ def start_of_option(param_str):
 def is_incomplete_option(all_args, cmd_param):
     """
     :param all_args: the full original list of args supplied
-    :param cmd_param: the current command parameter
+    :param cmd_param: the current command paramter
     :return: whether or not the last option declaration (i.e. starts
         "-" or "--") is incomplete and corresponds to this cmd_param. In
         other words whether this cmd_param option can still accept
diff --git a/src/click/_compat.py b/src/click/_compat.py
index cbc64a1..ed57a18 100644
--- a/src/click/_compat.py
+++ b/src/click/_compat.py
@@ -326,7 +326,7 @@ else:
 
     def _find_binary_writer(stream):
         # We need to figure out if the given stream is already binary.
-        # This can happen because the official docs recommend detaching
+        # This can happen because the official docs recommend detatching
         # the streams to get binary streams.  Some code might do this, so
         # we need to deal with this case explicitly.
         if _is_binary_writer(stream, False):
diff --git a/src/click/_termui_impl.py b/src/click/_termui_impl.py
index 704a1e1..c6e86cc 100644
--- a/src/click/_termui_impl.py
+++ b/src/click/_termui_impl.py
@@ -288,21 +288,8 @@ class ProgressBar(object):
 
         self.eta_known = self.length_known
 
-    def update(self, n_steps, current_item=None):
-        """Update the progress bar by advancing a specified number of
-        steps, and optionally set the ``current_item`` for this new
-        position.
-
-        :param n_steps: Number of steps to advance.
-        :param current_item: Optional item to set as ``current_item``
-            for the updated position.
-
-        .. versionadded:: 8.0
-            Added the ``current_item`` optional parameter.
-        """
+    def update(self, n_steps):
         self.make_step(n_steps)
-        if current_item is not None:
-            self.current_item = current_item
         self.render_progress()
 
     def finish(self):
@@ -490,20 +477,17 @@ class Editor(object):
         import tempfile
 
         text = text or ""
-        binary_data = type(text) in [bytes, bytearray]
-
-        if not binary_data and text and not text.endswith("\n"):
+        if text and not text.endswith("\n"):
             text += "\n"
 
         fd, name = tempfile.mkstemp(prefix="editor-", suffix=self.extension)
         try:
-            if not binary_data:
-                if WIN:
-                    encoding = "utf-8-sig"
-                    text = text.replace("\n", "\r\n")
-                else:
-                    encoding = "utf-8"
-                text = text.encode(encoding)
+            if WIN:
+                encoding = "utf-8-sig"
+                text = text.replace("\n", "\r\n")
+            else:
+                encoding = "utf-8"
+            text = text.encode(encoding)
 
             f = os.fdopen(fd, "wb")
             f.write(text)
@@ -520,10 +504,7 @@ class Editor(object):
                 rv = f.read()
             finally:
                 f.close()
-            if binary_data:
-                return rv
-            else:
-                return rv.decode("utf-8-sig").replace("\r\n", "\n")
+            return rv.decode("utf-8-sig").replace("\r\n", "\n")
         finally:
             os.unlink(name)
 
diff --git a/src/click/_winconsole.py b/src/click/_winconsole.py
index cae8ded..b6c4274 100644
--- a/src/click/_winconsole.py
+++ b/src/click/_winconsole.py
@@ -6,7 +6,7 @@
 # There are some general differences in regards to how this works
 # compared to the original patches as we do not need to patch
 # the entire interpreter but just work in our little world of
-# echo and prompt.
+# echo and prmopt.
 import ctypes
 import io
 import os
@@ -102,7 +102,7 @@ class Py_buffer(ctypes.Structure):
 
 
 # On PyPy we cannot get buffers so our ability to operate here is
-# severely limited.
+# serverly limited.
 if pythonapi is None:
     get_buffer = None
 else:
diff --git a/src/click/core.py b/src/click/core.py
index a405793..f58bf26 100644
--- a/src/click/core.py
+++ b/src/click/core.py
@@ -110,18 +110,16 @@ def invoke_param_callback(callback, ctx, param, value):
     args = getattr(code, "co_argcount", 3)
 
     if args < 3:
-        # This will become a warning in Click 3.0:
         from warnings import warn
 
         warn(
-            Warning(
-                "Invoked legacy parameter callback '{}'. The new"
-                " signature for such callbacks starting with Click 2.0"
-                " is (ctx, param, value).".format(callback)
-            ),
+            "Parameter callbacks take 3 args, (ctx, param, value). The"
+            " 2-arg style is deprecated and will be removed in 8.0.".format(callback),
+            DeprecationWarning,
             stacklevel=3,
         )
         return callback(ctx, value)
+
     return callback(ctx, param, value)
 
 
@@ -158,38 +156,6 @@ def iter_params_for_processing(invocation_order, declaration_order):
     return sorted(declaration_order, key=sort_key)
 
 
-class ParameterSource(object):
-    """This is an enum that indicates the source of a command line parameter.
-
-    The enum has one of the following values: COMMANDLINE,
-    ENVIRONMENT, DEFAULT, DEFAULT_MAP.  The DEFAULT indicates that the
-    default value in the decorator was used.  This class should be
-    converted to an enum when Python 2 support is dropped.
-    """
-
-    COMMANDLINE = "COMMANDLINE"
-    ENVIRONMENT = "ENVIRONMENT"
-    DEFAULT = "DEFAULT"
-    DEFAULT_MAP = "DEFAULT_MAP"
-
-    VALUES = {COMMANDLINE, ENVIRONMENT, DEFAULT, DEFAULT_MAP}
-
-    @classmethod
-    def validate(cls, value):
-        """Validate that the specified value is a valid enum.
-
-        This method will raise a ValueError if the value is
-        not a valid enum.
-
-        :param value: the string value to verify
-        """
-        if value not in cls.VALUES:
-            raise ValueError(
-                "Invalid ParameterSource value: '{}'. Valid "
-                "values are: {}".format(value, ",".join(cls.VALUES))
-            )
-
-
 class Context(object):
     """The context is a special internal object that holds state relevant
     for the script execution at every single level.  It's normally invisible
@@ -426,7 +392,6 @@ class Context(object):
 
         self._close_callbacks = []
         self._depth = 0
-        self._source_by_paramname = {}
 
     def __enter__(self):
         self._depth += 1
@@ -662,35 +627,6 @@ class Context(object):
 
         return self.invoke(cmd, **kwargs)
 
-    def set_parameter_source(self, name, source):
-        """Set the source of a parameter.
-
-        This indicates the location from which the value of the
-        parameter was obtained.
-
-        :param name: the name of the command line parameter
-        :param source: the source of the command line parameter, which
-                       should be a valid ParameterSource value
-        """
-        ParameterSource.validate(source)
-        self._source_by_paramname[name] = source
-
-    def get_parameter_source(self, name):
-        """Get the source of a parameter.
-
-        This indicates the location from which the value of the
-        parameter was obtained.  This can be useful for determining
-        when a user specified an option on the command line that is
-        the same as the default.  In that case, the source would be
-        ParameterSource.COMMANDLINE, even though the value of the
-        parameter was equivalent to the default.
-
-        :param name: the name of the command line parameter
-        :returns: the source
-        :rtype: ParameterSource
-        """
-        return self._source_by_paramname[name]
-
 
 class BaseCommand(object):
     """The base command implements the minimal API contract of commands.
@@ -900,8 +836,6 @@ class Command(BaseCommand):
 
     .. versionchanged:: 2.0
        Added the `context_settings` parameter.
-    .. versionchanged:: 8.0
-       Added repr showing the command name
     .. versionchanged:: 7.1
        Added the `no_args_is_help` parameter.
 
@@ -964,9 +898,6 @@ class Command(BaseCommand):
         self.hidden = hidden
         self.deprecated = deprecated
 
-    def __repr__(self):
-        return "<{} {}>".format(self.__class__.__name__, self.name)
-
     def get_usage(self, ctx):
         """Formats the usage line into a string and returns it.
 
@@ -1507,13 +1438,11 @@ class Parameter(object):
                     without any arguments.
     :param callback: a callback that should be executed after the parameter
                      was matched.  This is called as ``fn(ctx, param,
-                     value)`` and needs to return the value.  Before Click
-                     2.0, the signature was ``(ctx, value)``.
+                     value)`` and needs to return the value.
     :param nargs: the number of arguments to match.  If not ``1`` the return
                   value is a tuple instead of single value.  The default for
                   nargs is ``1`` (except if the type is a tuple, then it's
-                  the arity of the tuple). If ``nargs=-1``, all remaining
-                  parameters are collected.
+                  the arity of the tuple).
     :param metavar: how the value is represented in the help page.
     :param expose_value: if this is `True` then the value is passed onwards
                          to the command callback and stored on the context,
@@ -1609,15 +1538,10 @@ class Parameter(object):
 
     def consume_value(self, ctx, opts):
         value = opts.get(self.name)
-        source = ParameterSource.COMMANDLINE
         if value is None:
             value = self.value_from_envvar(ctx)
-            source = ParameterSource.ENVIRONMENT
         if value is None:
             value = ctx.lookup_default(self.name)
-            source = ParameterSource.DEFAULT_MAP
-        if value is not None:
-            ctx.set_parameter_source(self.name, source)
         return value
 
     def type_cast_value(self, ctx, value):
@@ -1666,8 +1590,6 @@ class Parameter(object):
 
         if value is None and not ctx.resilient_parsing:
             value = self.get_default(ctx)
-            if value is not None:
-                ctx.set_parameter_source(self.name, ParameterSource.DEFAULT)
 
         if self.required and self.value_is_missing(value):
             raise MissingParameter(ctx=ctx, param=self)
diff --git a/src/click/parser.py b/src/click/parser.py
index 95442af..f43ebfe 100644
--- a/src/click/parser.py
+++ b/src/click/parser.py
@@ -18,10 +18,6 @@ by the Python Software Foundation. This is limited to code in parser.py.
 Copyright 2001-2006 Gregory P. Ward. All rights reserved.
 Copyright 2002-2006 Python Software Foundation. All rights reserved.
 """
-# This code uses parts of optparse written by Gregory P. Ward and
-# maintained by the Python Software Foundation.
-# Copyright 2001-2006 Gregory P. Ward
-# Copyright 2002-2006 Python Software Foundation
 import re
 from collections import deque
 
diff --git a/src/click/termui.py b/src/click/termui.py
index 7f29eb6..02ef9e9 100644
--- a/src/click/termui.py
+++ b/src/click/termui.py
@@ -346,20 +346,6 @@ def progressbar(
                 process_chunk(chunk)
                 bar.update(chunks.bytes)
 
-    The ``update()`` method also takes an optional value specifying the
-    ``current_item`` at the new position. This is useful when used
-    together with ``item_show_func`` to customize the output for each
-    manual step::
-
-        with click.progressbar(
-            length=total_size,
-            label='Unzipping archive',
-            item_show_func=lambda a: a.filename
-        ) as bar:
-            for archive in zip_file:
-                archive.extract()
-                bar.update(archive.size, archive)
-
     .. versionadded:: 2.0
 
     .. versionadded:: 4.0


Test patch:
diff --git a/tests/test_compat.py b/tests/test_compat.py
index c26834a..7851ab8 100644
--- a/tests/test_compat.py
+++ b/tests/test_compat.py
@@ -14,7 +14,7 @@ def test_legacy_callbacks(runner):
     def cli(foo):
         click.echo(foo)
 
-    with pytest.warns(Warning, match="Invoked legacy parameter callback"):
+    with pytest.warns(DeprecationWarning, match="2-arg style"):
         result = runner.invoke(cli, ["--foo", "wat"])
         assert result.exit_code == 0
         assert "WAT" in result.output
diff --git a/tests/test_context.py b/tests/test_context.py
index 06cc907..b3a20c6 100644
--- a/tests/test_context.py
+++ b/tests/test_context.py
@@ -1,8 +1,5 @@
 # -*- coding: utf-8 -*-
-import pytest
-
 import click
-from click.core import ParameterSource
 
 
 def test_ensure_context_objects(runner):
@@ -264,65 +261,3 @@ def test_exit_not_standalone():
         ctx.exit(0)
 
     assert cli.main([], "test_exit_not_standalone", standalone_mode=False) == 0
-
-
-def test_parameter_source_default(runner):
-    @click.command()
-    @click.pass_context
-    @click.option("-o", "--option", default=1)
-    def cli(ctx, option):
-        click.echo(ctx.get_parameter_source("option"))
-
-    rv = runner.invoke(cli)
-    assert rv.output.rstrip() == ParameterSource.DEFAULT
-
-
-def test_parameter_source_default_map(runner):
-    @click.command()
-    @click.pass_context
-    @click.option("-o", "--option", default=1)
-    def cli(ctx, option):
-        click.echo(ctx.get_parameter_source("option"))
-
-    rv = runner.invoke(cli, default_map={"option": 1})
-    assert rv.output.rstrip() == ParameterSource.DEFAULT_MAP
-
-
-def test_parameter_source_commandline(runner):
-    @click.command()
-    @click.pass_context
-    @click.option("-o", "--option", default=1)
-    def cli(ctx, option):
-        click.echo(ctx.get_parameter_source("option"))
-
-    rv = runner.invoke(cli, ["-o", "1"])
-    assert rv.output.rstrip() == ParameterSource.COMMANDLINE
-    rv = runner.invoke(cli, ["--option", "1"])
-    assert rv.output.rstrip() == ParameterSource.COMMANDLINE
-
-
-def test_parameter_source_environment(runner):
-    @click.command()
-    @click.pass_context
-    @click.option("-o", "--option", default=1)
-    def cli(ctx, option):
-        click.echo(ctx.get_parameter_source("option"))
-
-    rv = runner.invoke(cli, auto_envvar_prefix="TEST", env={"TEST_OPTION": "1"})
-    assert rv.output.rstrip() == ParameterSource.ENVIRONMENT
-
-
-def test_parameter_source_environment_variable_specified(runner):
-    @click.command()
-    @click.pass_context
-    @click.option("-o", "--option", default=1, envvar="NAME")
-    def cli(ctx, option):
-        click.echo(ctx.get_parameter_source("option"))
-
-    rv = runner.invoke(cli, env={"NAME": "1"})
-    assert rv.output.rstrip() == ParameterSource.ENVIRONMENT
-
-
-def test_validate_parameter_source():
-    with pytest.raises(ValueError):
-        ParameterSource.validate("NOT_A_VALID_PARAMETER_SOURCE")
diff --git a/tests/test_termui.py b/tests/test_termui.py
index 003a269..99a6a47 100644
--- a/tests/test_termui.py
+++ b/tests/test_termui.py
@@ -285,54 +285,6 @@ def test_progressbar_update(runner, monkeypatch):
     assert "100%          " in lines[3]
 
 
-def test_progressbar_item_show_func(runner, monkeypatch):
-    fake_clock = FakeClock()
-
-    @click.command()
-    def cli():
-        with click.progressbar(
-            range(4), item_show_func=lambda x: "Custom {}".format(x)
-        ) as progress:
-            for _ in progress:
-                fake_clock.advance_time()
-                print("")
-
-    monkeypatch.setattr(time, "time", fake_clock.time)
-    monkeypatch.setattr(click._termui_impl, "isatty", lambda _: True)
-    output = runner.invoke(cli, []).output
-
-    lines = [line for line in output.split("\n") if "[" in line]
-
-    assert "Custom 0" in lines[0]
-    assert "Custom 1" in lines[1]
-    assert "Custom 2" in lines[2]
-    assert "Custom None" in lines[3]
-
-
-def test_progressbar_update_with_item_show_func(runner, monkeypatch):
-    fake_clock = FakeClock()
-
-    @click.command()
-    def cli():
-        with click.progressbar(
-            length=6, item_show_func=lambda x: "Custom {}".format(x)
-        ) as progress:
-            while not progress.finished:
-                fake_clock.advance_time()
-                progress.update(2, progress.pos)
-                print("")
-
-    monkeypatch.setattr(time, "time", fake_clock.time)
-    monkeypatch.setattr(click._termui_impl, "isatty", lambda _: True)
-    output = runner.invoke(cli, []).output
-
-    lines = [line for line in output.split("\n") if "[" in line]
-
-    assert "Custom 0" in lines[0]
-    assert "Custom 2" in lines[1]
-    assert "Custom 4" in lines[2]
-
-
 @pytest.mark.parametrize("key_char", (u"h", u"H", u"é", u"À", u" ", u"字", u"àH", u"àR"))
 @pytest.mark.parametrize("echo", [True, False])
 @pytest.mark.skipif(not WIN, reason="Tests user-input using the msvcrt module.")