Skip to content

Conversation

@kmvanbrunt
Copy link
Member

Allowing the use of ~user tab completion in paths

Copy link
Member

@tleonhardt tleonhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Consider dealing with the following unused local variables in the _print_topcis() method:

  • help_topics
  • doc


users = []

# Windows lacks the pwd module so we can't get a list of users.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice comments throughout

Copy link
Member

@tleonhardt tleonhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix failing unit tests on AppVeyor.

Your code and unit tests look fine to me and pass on my Windows VM.

Potentially just skip the one failing test if you can't find a workaround.

assert cmd2_app.path_complete(text, line, begidx, endidx) == []
def test_path_completion_expand_user_dir(cmd2_app):
# Get the current user
user = getpass.getuser()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason this is causing a unit test failure on the AppVeyor Windows CI build/test systems. All unit tests pass for this branch on my Windows 10 VM for both Python 3.6 and 2.7.

But for some reason this is hosed on AppVeyor. As far as I can tell, the problem is with AppVeyor and not with the code.

If you can't find a good workaround quickly, I recommend just skipping this test on Windows.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason getpass.getuser() fails when running on AppVeyor. The user must not have any of these environment variables. Unfortunately the fallback imports the pwd module which doesn't exist on Windows.

for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
            user = os.environ.get(name)
            if user:
                return user

# If this fails, the exception will "explain" why
import pwd
return pwd.getpwuid(os.getuid())[0]

I am trying a workaround.

@codecov
Copy link

codecov bot commented Apr 13, 2018

Codecov Report

Merging #352 into master will increase coverage by 0.11%.
The diff coverage is 93.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #352      +/-   ##
==========================================
+ Coverage   89.64%   89.75%   +0.11%     
==========================================
  Files           1        1              
  Lines        2008     2021      +13     
==========================================
+ Hits         1800     1814      +14     
+ Misses        208      207       -1
Impacted Files Coverage Δ
cmd2.py 89.75% <93.93%> (+0.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 95bd80e...ff63a70. Read the comment docs.

Copy link
Member

@tleonhardt tleonhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go as long as all tests pass.

Consider talking with Eric about cleaning up the unused local variables ...

def test_path_completion_expand_user_dir(cmd2_app):
# Get the current user. We can't use getpass.getuser() since
# that doesn't work when running these tests on Windows in AppVeyor.
user = os.path.basename(os.path.expanduser('~'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming the unit test all pass, this looks OK. They still pass on my system.

@kmvanbrunt kmvanbrunt merged commit 8029d54 into master Apr 13, 2018
@kmvanbrunt kmvanbrunt deleted the user_expansion branch April 13, 2018 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants