Skip to content

Commit

Permalink
Add warning for upcoming Python default change
Browse files Browse the repository at this point in the history
  • Loading branch information
BanzaiMan committed Apr 8, 2019
1 parent a8d57ff commit a7cc958
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/travis/build/script/python.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ class Python < Script
virtualenv: { system_site_packages: false }
}

DEPRECATIONS = [
{
name: 'Python',
current_default: DEFAULTS[:phython],
new_default: '3.6',
cutoff_date: '2019-04-16',
}
]

REQUIREMENTS_MISSING = 'Could not locate requirements.txt. Override the install: key in your .travis.yml to install dependencies.'
SCRIPT_MISSING = 'Please override the script: key in your .travis.yml to run tests.'

Expand Down
31 changes: 31 additions & 0 deletions spec/build/script/python_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,37 @@
should include_sexp [:cmd, 'source ~/virtualenv/python2.7/bin/activate', assert: true, echo: true, timing: true]
end

context "with minimal config" do
before do
data[:config][:language] = 'python'; data[:config].delete(:python)
described_class.send :remove_const, :DEPRECATIONS
described_class.const_set("DEPRECATIONS", [
{
name: 'Python',
current_default: '2.7',
new_default: '3.5',
cutoff_date: '2020-01-01',
}
])
end

context "before default change cutoff date" do
before do
DateTime.stubs(:now).returns(DateTime.parse("2019-12-01"))
end
it { store_example name: "update-default-before-cutoff" }
it { should include_sexp [:echo, /Using the default Python version/, ansi: :yellow] }
end

context "after default change cutoff date" do
before do
DateTime.stubs(:now).returns(DateTime.parse("2020-02-01"))
end
it { should_not include_sexp [:echo, /Using the default Python version/, ansi: :yellow] }
end
end


context "when python version is given as an array" do
before { data[:config][:python] = %w(2.7) }
it 'sets up the python version (2.7)' do
Expand Down

0 comments on commit a7cc958

Please sign in to comment.