Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
JavaScript adding "·" character to endline

So I'm trying to run a tests.js for a python code I've written, everything seems fine however at the end of each line ("\n" character), the tests.js file is appending a "·" character. The file internally uses the toString() method to convert the python output to a string and then compares it with the expected string using toEqual().

My code:

def print_help():
    print("""Usage :-
$ ./task add 2 hello world    # Add a new item with priority 2 and text "hello world" to the list
$ ./task ls                   # Show incomplete priority list items sorted by priority in ascending order
$ ./task del INDEX            # Delete the incomplete item with the given index
$ ./task done INDEX           # Mark the incomplete item with the given index as complete
$ ./task help                 # Show usage
$ ./task report               # Statistics""", end="")

The output: error

The tests.js code:

test("prints help", () => {
  let received = execSync(tasksTxtCli("help")).toString("utf8");

  expect(received).toEqual(expect.stringContaining(usage));
});
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I don't know what you're using for your output in Node.js, but it's likely that this isn't actually a middle dot character, but an otherwise unprintable character by your terminal emulator.

In other words, what you're seeing isn't really there. It's just that something is there.

I expect that this is a difference between \r\n and \n for newline characters. Your comparison string probably doesn't have \r\n, but the Python output probably does.

If you want to be really sure as to what it is, pipe your Python output to a file and open it up with a hex editor. Or even, just don't convert to a string and use console.log() (or util.inspect()) to see a hex representation of the binary output.

about 4 years ago · Juan Pablo Isaza Relatório

0

As per my solution modify your code as:

def print_help():
    help="""Usage :-
$ ./task add 2 hello world    # Add a new item with priority 2 and text "hello world" to the list
$ ./task ls                   # Show incomplete priority list items sorted by priority in ascending order
$ ./task del INDEX            # Delete the incomplete item with the given index
$ ./task done INDEX           # Mark the incomplete item with the given index as complete
$ ./task help                 # Show usage
$ ./task report               # Statistics"""
    sys.stdout.buffer.write(help.encode('utf8'))

In this way , the dot(.) won't appear on command line. Reference: https://github.com/nseadlc-2020/package-todo-cli-task/issues/12

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda