Giter VIP home page Giter VIP logo

Comments (7)

myint avatar myint commented on July 20, 2024

Good point.

from autoflake.

myint avatar myint commented on July 20, 2024

I took a look and I think it probably isn't worth the effort. I only have a few actual top-level tests. Most of the tests are unit tests that test lower-level functions. (It might be useful for autopep8 though, where we have hundreds of tests.)

And test_acid.py sort of already does this on a more broader scale.

$ ./test_acid.py --help
usage: test_acid.py [-h] [--command COMMAND] [--timeout TIMEOUT]
                    [--imports IMPORTS] [--remove-all-unused-imports]
                    [--remove-unused-variables] [-v]
                    [files [files ...]]

positional arguments:
  files                 files to format

optional arguments:
  -h, --help            show this help message and exit
  --command COMMAND     autoflake command (default:
                        /Users/myint/projects/autoflake/autoflake)
  --timeout TIMEOUT     stop testing additional files after this amount of
                        time (default: -1.0)
  --imports IMPORTS     pass to the autoflake "--imports" option
  --remove-all-unused-imports
                        pass "--remove-all-unused-imports" option to autoflake
  --remove-unused-variables
                        pass "--remove-unused-variables" option to autoflake
  -v, --verbose         print verbose messages
$ ./test_acid.py --verbose
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/__init__.py
--- /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/__init__.py
+++ ./lpearl/__init__.py
@@ -7,7 +7,8 @@

 from pip.exceptions import InstallationError, CommandError, PipError
 from pip.log import logger
-from pip.util import get_installed_distributions, get_prog
+from pip.util import get_installed_distributions
+from pip.util import get_prog
 from pip.vcs import git, mercurial, subversion, bazaar  # noqa
 from pip.baseparser import create_main_parser
 from pip.commands import commands, get_similar_commands, get_summaries
(before, after): (5, 5)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/__main__.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/basecommand.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/baseparser.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/cmdoptions.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/download.py
(before, after): (1, 1)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/exceptions.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/index.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/locations.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/log.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/pep425tags.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/req.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/runner.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/status_codes.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/util.py
--- /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/util.py
+++ ./k0a2fm/util.py
@@ -8,8 +8,9 @@
 import zipfile
 import tarfile
 import subprocess
-import textwrap
-from pip.exceptions import InstallationError, BadCommand, PipError
+from pip.exceptions import InstallationError
+from pip.exceptions import BadCommand
+from pip.exceptions import PipError
 from pip.backwardcompat import(WindowsError, string_types, raw_input,
                                 console_to_str, user_site, PermissionError)
 from pip.locations import site_packages, running_under_virtualenv, virtualenv_no_global
(before, after): (5, 4)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/wheel.py
(before, after): (1, 1)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/backwardcompat/__init__.py
--- /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/backwardcompat/__init__.py
+++ ./dnqwa1/__init__.py
@@ -1,6 +1,5 @@
 """Stuff that differs in different Python versions"""

-import os
 import imp
 import sys
 import site
@@ -30,10 +29,6 @@
     from functools import reduce
     from urllib.error import URLError, HTTPError
     from queue import Queue, Empty
-    from urllib.request import url2pathname
-    from urllib.request import urlretrieve
-    from email import message as emailmessage
-    import urllib.parse as urllib
     import urllib.request as urllib2
     import configparser as ConfigParser
     import xmlrpc.client as xmlrpclib
@@ -66,11 +61,10 @@
     raw_input = input
 else:
     from cStringIO import StringIO
-    from urllib2 import URLError, HTTPError
-    from Queue import Queue, Empty
-    from urllib import url2pathname, urlretrieve
-    from email import Message as emailmessage
-    import urllib
+    from urllib2 import URLError
+    from urllib2 import HTTPError
+    from Queue import Queue
+    from Queue import Empty
     import urllib2
     import urlparse
     import ConfigParser
@@ -101,7 +95,6 @@
     BytesIO = StringIO


-from distutils.sysconfig import get_python_lib, get_python_version

 #site.USER_SITE was created in py2.6
 user_site = getattr(site, 'USER_SITE', None)
@@ -122,4 +115,5 @@
 try:
     from ssl import match_hostname, CertificateError
 except ImportError:
-    from ssl_match_hostname import match_hostname, CertificateError
+    from ssl_match_hostname import match_hostname
+    from ssl_match_hostname import CertificateError
(before, after): (19, 12)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/backwardcompat/ssl_match_hostname.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/commands/__init__.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/commands/bundle.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/commands/completion.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/commands/freeze.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/commands/help.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/commands/install.py
--- /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/commands/install.py
+++ ./j93cbo/install.py
@@ -1,5 +1,4 @@
 import os
-import sys
 import tempfile
 import shutil
 from pip.req import InstallRequirement, RequirementSet, parse_requirements
(before, after): (1, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/commands/list.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/commands/search.py
(before, after): (1, 1)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/commands/show.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/commands/uninstall.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/commands/unzip.py
(before, after): (0, 0)
--->  Testing with /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/commands/wheel.py
--- /Users/myint/Library/Python/3.3/lib/python/site-packages/pip-1.5.dev1-py3.3.egg/pip/commands/wheel.py
+++ ./mn2yo4/wheel.py
@@ -2,7 +2,6 @@
 from __future__ import absolute_import

 import os
-import sys
 from pip.basecommand import Command
 from pip.index import PackageFinder
 from pip.log import logger
(before, after): (2, 1)

from autoflake.

twolfson avatar twolfson commented on July 20, 2024

The purpose here is not to be able to test that the library works with a Python file. it is to:

  • Remove cost of contributors to learn test suite functionality
  • Reduce cost of finding pre-existing tests
  • Reduce cost of adding new tests

Tests should be as easy to add as possible so that you can test what you just implemented and move on to the next thing. Here is a good short article:

http://jonjagger.blogspot.ie/2011/07/why-do-cars-have-brakes.html

I will open an issue on autopep8.

from autoflake.

myint avatar myint commented on July 20, 2024

I wouldn't be against accepting such a pull request in autopep8. That project's tests are mostly composed of system tests. (Though personally, I wish there were more unit tests, which I find easier to reason about.)

from autoflake.

myint avatar myint commented on July 20, 2024

By the way, I took a look at that link. It is about tests being useful, which I agree with strongly. But it says nothing about the points you listed.

from autoflake.

twolfson avatar twolfson commented on July 20, 2024

Useful is a vague term; a wrench is useful, a door is useful, a car is useful. The purpose of the article is to provoke thought and let you draw your own conclusions, I came to the conclusions I listed above.

If you don't see how I arrived at those ones, I cannot show you the path since it is a confluence of past and present thoughts, however I can try to explain the benefits of them further.

from autoflake.

myint avatar myint commented on July 20, 2024

(I wasn't disagreeing. It just seemed unrelated. I thought it was copy and paste error or something.)

from autoflake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.