Skip to content
This repository was archived by the owner on Oct 1, 2019. It is now read-only.

Add env flag for running tests with pycodestyle #70

Merged
merged 1 commit into from
May 4, 2018

Conversation

ryanashcraft
Copy link
Collaborator

Proof of concept for #1. Curious if others think this is actually useful or not.

Add optional support for a PEP8_VALIDATE env flag for running prettier output from tests into pycodestyle. If pycodestyle returns any errors, the test fails. There is no impact if the PEP8_VALIDATE flag is not set.

I did my best choosing an appropriate subset of pycodestyle errors, but it will likely will need more tweaking.

Adds pycodestyle as a vendor dependency.

Several tests currently fail with the PEP8_VALIDATE flag enabled:

Click to view output
Summary of all failing tests
 FAIL  tests/python_comments/jsfmt.spec.js
  ● comments.py - python-verify

    expect(received).toEqual(expected)
    
    Expected value to equal:
      ""
    Received:
      "stdin:1:6: E261 at least two spaces before inline comment
    "
      
      at Object.test (tests_config/run_spec.js:46:63)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  ● comments.py - python-verify

    expect(received).toEqual(expected)
    
    Expected value to equal:
      ""
    Received:
      "stdin:1:6: E261 at least two spaces before inline comment
    "
      
      at Object.test (tests_config/run_spec.js:46:63)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

 FAIL  tests/python_expressions/jsfmt.spec.js
  ● expressions.py - python-verify

    expect(received).toEqual(expected)
    
    Expected value to equal:
      ""
    Received:
      "stdin:37:4: E231 missing whitespace after ','
    stdin:110:11: E203 whitespace before ':'
    stdin:334:18: E231 missing whitespace after ','
    "
      
      at Object.test (tests_config/run_spec.js:46:63)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  ● expressions.py - python-verify

    expect(received).toEqual(expected)
    
    Expected value to equal:
      ""
    Received:
      "stdin:37:4: E231 missing whitespace after ','
    stdin:110:11: E203 whitespace before ':'
    stdin:334:18: E231 missing whitespace after ','
    "
      
      at Object.test (tests_config/run_spec.js:46:63)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

 FAIL  tests/python_tuple/jsfmt.spec.js
  ● tuple.py - python-verify

    expect(received).toEqual(expected)
    
    Expected value to equal:
      ""
    Received:
      "stdin:13:4: E231 missing whitespace after ','
    stdin:14:4: E231 missing whitespace after ','
    "
      
      at Object.test (tests_config/run_spec.js:46:63)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  ● tuple.py - python-verify

    expect(received).toEqual(expected)
    
    Expected value to equal:
      ""
    Received:
      "stdin:13:4: E231 missing whitespace after ','
    stdin:14:4: E231 missing whitespace after ','
    "
      
      at Object.test (tests_config/run_spec.js:46:63)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  ● tuple.py - python-verify

    expect(received).toEqual(expected)
    
    Expected value to equal:
      ""
    Received:
      "stdin:13:4: E231 missing whitespace after ','
    stdin:14:4: E231 missing whitespace after ','
    "
      
      at Object.test (tests_config/run_spec.js:46:63)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

 FAIL  tests/python_strings/jsfmt.spec.js
  ● strings.py - python-verify

    expect(received).toEqual(expected)
    
    Expected value to equal:
      ""
    Received:
      "stdin:43:1: E265 block comment should start with '# '
    "
      
      at Object.test (tests_config/run_spec.js:46:63)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  ● strings.py - python-verify

    expect(received).toEqual(expected)
    
    Expected value to equal:
      ""
    Received:
      "stdin:43:1: E265 block comment should start with '# '
    "
      
      at Object.test (tests_config/run_spec.js:46:63)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

 FAIL  tests/python_lambdas/jsfmt.spec.js
  ● lambdas.py - python-verify

    expect(received).toEqual(expected)
    
    Expected value to equal:
      ""
    Received:
      "stdin:4:9: E126 continuation line over-indented for hanging indent
    stdin:6:9: E126 continuation line over-indented for hanging indent
    stdin:8:47: E203 whitespace before ':'
    stdin:9:5: E131 continuation line unaligned for hanging indent
    "
      
      at Object.test (tests_config/run_spec.js:46:63)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  ● lambdas.py - python-verify

    expect(received).toEqual(expected)
    
    Expected value to equal:
      ""
    Received:
      "stdin:4:9: E126 continuation line over-indented for hanging indent
    stdin:6:9: E126 continuation line over-indented for hanging indent
    stdin:9:5: E131 continuation line unaligned for hanging indent
    "
      
      at Object.test (tests_config/run_spec.js:46:63)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  ● lambdas.py - python-verify

    expect(received).toEqual(expected)
    
    Expected value to equal:
      ""
    Received:
      "stdin:4:9: E126 continuation line over-indented for hanging indent
    stdin:6:9: E126 continuation line over-indented for hanging indent
    stdin:8:47: E203 whitespace before ':'
    stdin:9:5: E131 continuation line unaligned for hanging indent
    "
      
      at Object.test (tests_config/run_spec.js:46:63)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

 FAIL  tests/python_long/jsfmt.spec.js
  ● hello.py - python-verify

    expect(received).toEqual(expected)
    
    Expected value to equal:
      ""
    Received:
      "stdin:1:1: E302 expected 2 blank lines, found 0
    "
      
      at Object.test (tests_config/run_spec.js:46:63)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  ● hello.py - python-verify

    expect(received).toEqual(expected)
    
    Expected value to equal:
      ""
    Received:
      "stdin:1:1: E302 expected 2 blank lines, found 0
    "
      
      at Object.test (tests_config/run_spec.js:46:63)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  ● hello.py - python-verify

    expect(received).toEqual(expected)
    
    Expected value to equal:
      ""
    Received:
      "stdin:1:1: E302 expected 2 blank lines, found 0
    "
      
      at Object.test (tests_config/run_spec.js:46:63)
          at new Promise (<anonymous>)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)


Test Suites: 6 failed, 118 passed, 124 total
Tests:       15 failed, 165 passed, 180 total
Snapshots:   113 passed, 113 total
Time:        12.275s
Ran all test suites in 2 projects.

Add optional PEP8_VALIDATE env flag for running prettier output from
tests into pycodestyle. If pycodestyle returns any errors, the test
fails.

Adds pycodestyle as a vendor dependency.

Several tests currently fail with the PEP8_VALIDATE flag enabled.

Proof of concept for prettier#1.
@FuegoFro
Copy link
Collaborator

This looks great to me! I think that having this option, even if it's not on or enforced by default, makes it a lot easier to start tracking down and fixing inconsistencies/issues as we start to get more feature complete. I'd be in favor of merging this in :D

@ryanashcraft
Copy link
Collaborator Author

@patrick91 Do you have any feedback for this PR?

@patrick91 patrick91 mentioned this pull request May 4, 2018
@patrick91
Copy link
Member

@ryanashcraft I'm so sorry for the delay, I've been busy with PyCon Italia and other things, the PR looks great! I'll merge it and we can enable pycodestyle on CI later

@patrick91 patrick91 merged commit d75742f into prettier:master May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants