Are homotopy-preserving maps continuous? I was thinking some about weak homotopy equivalences and what happens when you drop the continuity assumption.
For example, it's not too hard to come up with non-continuous functions that induce isomorphisms on all homotopy groups (and a bijection on connected components): let $X$ be any contractible space, then the identity map $\operatorname{codisc}X\to X$ from the codiscrete topology on $X$ is not continuous in general, but it trivially induces isomorphisms of all $\pi_n$ as both spaces are contractible.
My question is if continuity remains unnecessary if I strengthen the assumptions a bit from just inducing homomorphisms of homotopy groups to actually just preserving homotopies:
Question: Does there exist a non-continuous map $f:X\to Y$ such that $\def\bS{\mathbb{S}}fg:\bS^n\to Y$ is continuous for all continuous $g:\bS^n\to X$ and $n\geq0$, where $\bS^n$ is the $n$-sphere?
I want to believe that the answer is yes, but I am drawing blanks for an explicit example.
I thought to use length constraints on homotopies like what happens with the long line (each individual homotopy is "too small" to see everything), but I couldn't put it into practice.
If the answer to the question is indeed yes, then how nice can $X$ and $Y$ be with $f$ still existing? For instance, can $X$ and $Y$ be compactly generated and (weakly) Hausdorff?
 A: If you do not impose some hypothesis related to path-connectedness on $X$, then there are essentially arbitrarily nice counterexamples.  For example, let $X$ any totally path-disconnected space (e.g., $\mathbb{N}\cup\{\infty\}$ which is additionally compact Hausdorff) and $Y$ be any space.  Then every map $f:X\to Y$ has continuous composition with every map from a sphere, so such a counterexample exists unless every map from $X$ to $Y$ is continuous.
Note that spheres are a bit of a red herring here--it's equivalent to ask for the same condition with $\mathbb{R}$ (or $[0,1]$) in place of spheres.  One direction is easy (any interval in $\mathbb{R}$ can be written as a quotient of a sphere so if you have continuity after composing with maps from spheres you get continuity after composing with maps from $\mathbb{R}$).  The other direction is nontrivial (see below).
More generally, say a space $X$ is $\mathbb{R}$-generated if for every space $Y$ and every function $f:X\to Y$, $f$ is continuous iff its composition with each continuous map $\mathbb{R}\to X$ is continuous.  I discuss such spaces in detail in this answer.  In particular, every locally path-connected first-countable space is $\mathbb{R}$-generated, as is every CW-complex, and every $\mathbb{R}$-generated space is locally path-connected.  If $Z$ is $\mathbb{R}$-generated and $f:X\to Y$ has the property that its composition with every continuous map $\mathbb{R}\to X$ is continuous, then $f$ also has the same property with respect to maps $Z\to X$.  In particular, taking $Z$ to be the spheres, this proves the nontrivial direction mentioned in the previous paragraph.  It follows that the $\mathbb{R}$-generated spaces are exactly the spaces $X$ for which no counterexample $f:X\to Y$ exists to your question.
