diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb index f8d1374822..75a882d693 100644 --- a/Library/Homebrew/test/audit_test.rb +++ b/Library/Homebrew/test/audit_test.rb @@ -361,13 +361,10 @@ class FormulaAuditorTests < Homebrew::TestCase end EOS - original_value = ENV["HOMEBREW_NO_GITHUB_API"] ENV["HOMEBREW_NO_GITHUB_API"] = "1" fa.audit_github_repository assert_equal [], fa.problems - ensure - ENV["HOMEBREW_NO_GITHUB_API"] = original_value end def test_audit_caveats diff --git a/Library/Homebrew/test/commands_test.rb b/Library/Homebrew/test/commands_test.rb index 3d7c16e58f..5f5dc95865 100644 --- a/Library/Homebrew/test/commands_test.rb +++ b/Library/Homebrew/test/commands_test.rb @@ -47,8 +47,6 @@ class CommandsTests < Homebrew::TestCase end def test_external_commands - env = ENV.to_hash - mktmpdir do |dir| %w[brew-t1 brew-t2.rb brew-t3.py].each do |file| path = "#{dir}/#{file}" @@ -67,8 +65,6 @@ class CommandsTests < Homebrew::TestCase "Executable files with a non Ruby extension shoudn't be included" refute cmds.include?("t4"), "Non-executable files shouldn't be included" end - ensure - ENV.replace(env) end def test_internal_command_path diff --git a/Library/Homebrew/test/diagnostic_test.rb b/Library/Homebrew/test/diagnostic_test.rb index 2d12868273..7a1fb25f79 100644 --- a/Library/Homebrew/test/diagnostic_test.rb +++ b/Library/Homebrew/test/diagnostic_test.rb @@ -6,15 +6,9 @@ require "diagnostic" class DiagnosticChecksTest < Homebrew::TestCase def setup super - @env = ENV.to_hash @checks = Homebrew::Diagnostic::Checks.new end - def teardown - ENV.replace(@env) - super - end - def test_inject_file_list assert_equal "foo:\n", @checks.inject_file_list([], "foo:\n") diff --git a/Library/Homebrew/test/os/mac/diagnostic_test.rb b/Library/Homebrew/test/os/mac/diagnostic_test.rb index 284d293ca9..5f467e87be 100644 --- a/Library/Homebrew/test/os/mac/diagnostic_test.rb +++ b/Library/Homebrew/test/os/mac/diagnostic_test.rb @@ -6,15 +6,9 @@ require "diagnostic" class OSMacDiagnosticChecksTest < Homebrew::TestCase def setup super - @env = ENV.to_hash @checks = Homebrew::Diagnostic::Checks.new end - def teardown - ENV.replace(@env) - super - end - def test_check_for_other_package_managers MacOS.stubs(:macports_or_fink).returns ["fink"] assert_match "You have MacPorts or Fink installed:", diff --git a/Library/Homebrew/test/shell_test.rb b/Library/Homebrew/test/shell_test.rb index 877acb5c8b..a32d098638 100644 --- a/Library/Homebrew/test/shell_test.rb +++ b/Library/Homebrew/test/shell_test.rb @@ -37,7 +37,6 @@ class ShellSmokeTest < Homebrew::TestCase end def prepend_path_shell(shell, path, fragment) - original_shell = ENV["SHELL"] ENV["SHELL"] = shell prepend_message = Utils::Shell.prepend_path_in_shell_profile(path) @@ -45,8 +44,6 @@ class ShellSmokeTest < Homebrew::TestCase prepend_message.start_with?(fragment), "#{shell}: expected #{prepend_message} to match #{fragment}" ) - - ENV["SHELL"] = original_shell end def test_prepend_path_in_shell_profile diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index 53d4e70317..c4c7f87275 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -16,11 +16,14 @@ module Homebrew def setup super + @__argv = ARGV.dup + @__env = copy_env # Call #to_hash to duplicate ENV end def teardown ARGV.replace(@__argv) + restore_env @__env Tab.clear_cache diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb index 7099e332c2..7ff4e192ac 100644 --- a/Library/Homebrew/test/utils_test.rb +++ b/Library/Homebrew/test/utils_test.rb @@ -7,12 +7,6 @@ class UtilTests < Homebrew::TestCase def setup super @dir = Pathname.new(mktmpdir) - @env = ENV.to_hash - end - - def teardown - ENV.replace @env - super end def test_ofail