aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authormansimarkaur2017-07-23 22:50:39 +0530
committermansimarkaur2017-07-25 21:00:37 +0530
commitae02b9776a8e0d2456a71f1317218b73998779e7 (patch)
tree532e4732241125983690b66b53b98540d03200d9 /Library
parent9218d3014d6b97a0225e537b6227eca885dd1260 (diff)
downloadbrew-ae02b9776a8e0d2456a71f1317218b73998779e7.tar.bz2
Added tests for python caveats
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/caveats.rb2
-rw-r--r--Library/Homebrew/test/caveats_spec.rb42
2 files changed, 42 insertions, 2 deletions
diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb
index 172d3c73f..1f9a09bec 100644
--- a/Library/Homebrew/caveats.rb
+++ b/Library/Homebrew/caveats.rb
@@ -196,7 +196,7 @@ class Caveats
s << " #{f.plist_manual}"
end
- # pbpaste pastes the system clipboard tool on macOS and fails with `tmux` by default
+ # pbpaste is the system clipboard tool on macOS and fails with `tmux` by default
# check if this is being run under `tmux` to avoid failing
if ENV["TMUX"] && !quiet_system("/usr/bin/pbpaste")
s << "" << "WARNING: brew services will fail when run under tmux."
diff --git a/Library/Homebrew/test/caveats_spec.rb b/Library/Homebrew/test/caveats_spec.rb
index e04e4eab3..53c90d60a 100644
--- a/Library/Homebrew/test/caveats_spec.rb
+++ b/Library/Homebrew/test/caveats_spec.rb
@@ -28,7 +28,7 @@ describe Caveats do
end
describe "#caveats" do
- context "when f.plist is not nil" do
+ context "when f.plist is not nil", :needs_macos do
it "prints plist startup information when f.plist_startup is not nil" do
f = formula do
url "foo-1.0"
@@ -201,5 +201,45 @@ describe Caveats do
expect(caveats).to include(HOMEBREW_PREFIX/"share/fish/vendor_completions.d")
end
end
+
+ context "python caveats" do
+ before do
+ (f.prefix.resolved_path/"lib/python2.7/site-packages").mkpath
+ end
+
+ context "when f is not keg_only" do
+ let(:f) {
+ formula do
+ url "foo-1.0"
+ end
+ }
+ let(:caveats) { described_class.new(f).caveats }
+ let(:user_site_packages) { Language::Python.user_site_packages("python") }
+
+ it "give commands to run when Homebrew's site-packages is not in Python sys.path" do
+ expect(caveats).to include("Homebrew's site-packages is not\nin your Python sys.path")
+ expect(caveats).to include(user_site_packages)
+ expect(caveats).to include("import site")
+ end
+
+ it "gives commands to run when python pth files are installed" do
+ allow(Homebrew).to receive(:_system).and_return(true)
+ allow(Dir).to receive(:[]).with(any_args).and_return(["blah.pth"])
+ expect(caveats).to include(".pth files to Homebrew's site-packages and your\nPython isn't configured")
+ expect(caveats).to include(user_site_packages)
+ expect(caveats).to include("import site")
+ end
+ end
+
+ it "gives commands to run when formula is keg_only" do
+ f = formula do
+ url "foo-1.0"
+ keg_only "some reason"
+ end
+ caveats = described_class.new(f).caveats
+ homebrew_site_packages = Language::Python.homebrew_site_packages
+ expect(caveats).to include("echo #{f.opt_prefix}/lib/python2.7/site-packages >> #{homebrew_site_packages/f.name}.pth")
+ end
+ end
end
end