Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning for upcoming Python default change #1681

Merged
merged 2 commits into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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[:python],
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