Skip to content

Commit

Permalink
Deprecation of CONAN_USERNAME and CONAN_CHANNEL: fix error message (#…
Browse files Browse the repository at this point in the history
…5756)

* if CONAN_USERNAME and CONAN_CHANNEL are deprecated, the error cannot recommend them

* update tests accordingly
  • Loading branch information
jgsogo authored and lasote committed Sep 25, 2019
1 parent a845441 commit db41360
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions conans/model/conan_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,15 @@ def channel(self):
if not self._conan_channel:
self._conan_channel = os.getenv("CONAN_CHANNEL") or self.default_channel
if not self._conan_channel:
raise ConanException("CONAN_CHANNEL environment variable not defined, "
"but self.channel is used in conanfile")
raise ConanException("channel not defined, but self.channel is used in conanfile")
return self._conan_channel

@property
def user(self):
if not self._conan_user:
self._conan_user = os.getenv("CONAN_USERNAME") or self.default_user
if not self._conan_user:
raise ConanException("CONAN_USERNAME environment variable not defined, "
"but self.user is used in conanfile")
raise ConanException("user not defined, but self.user is used in conanfile")
return self._conan_user

def collect_libs(self, folder=None):
Expand Down
8 changes: 4 additions & 4 deletions conans/test/integration/same_userchannel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ def test_local_commands(self):
self.client.run("install .", assert_error=True)
self.assertIn("ERROR: conanfile.py (Hello/0.1): "
"Error in requirements() method, line 10", self.client.out)
self.assertIn("ConanException: CONAN_USERNAME environment "
"variable not defined, but self.user is used", self.client.out)
self.assertIn("ConanException: user not defined, but self.user is used in"
" conanfile", self.client.out)

os.environ["CONAN_USERNAME"] = "lasote"
self.client.run("install .", assert_error=True)
self.assertIn("ERROR: conanfile.py (Hello/0.1): "
"Error in requirements() method, line 10", self.client.out)
self.assertIn("ConanException: CONAN_CHANNEL environment "
"variable not defined, but self.channel is used", self.client.out)
self.assertIn("ConanException: channel not defined, but self.channel is used in"
" conanfile", self.client.out)

os.environ["CONAN_CHANNEL"] = "stable"
self.client.run("install .")
Expand Down

0 comments on commit db41360

Please sign in to comment.